Atia Amin
Atia Amin

Reputation: 429

Creating empirical distribution function in R using ggplot2 stat_ecdf

I am trying to make a ggplot plot for empirical distribution function stat_ecdf but I am getting the the following error. Any help on how to resolve this? Here d is a double list.

library(ggplot2)
 >> d
 [1] 9.126560 8.837303 6.942810 9.515659 7.614937 9.190298 6.866715 6.322031
 [9] 8.846318 7.181234 9.104691 7.187005 7.371961 7.180689 9.117338 9.174383
[17] 7.209469 9.030088 9.519537 8.987137 7.044774 7.566912 6.845430 9.370125
 >> typeof(d)
[1] "double"
 >> ggplot(data.frame(d), aes(expression)) + stat_ecdf(geom = "point")
Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 0, 24

Upvotes: 0

Views: 257

Answers (1)

Paul
Paul

Reputation: 9087

aes needs to contain column for x.

ggplot(data.frame(x = d), aes(x)) + stat_ecdf(geom = "point")

Upvotes: 1

Related Questions