install.packages("UsingR")
library(UsingR)
x <- father.son$fheight
round(sample(x,10),1)
smallest <- floor(min(x))
largest <- ceiling(max(x))
values <- seq(smallest, largest, len = 300)
heightcdf <- ecdf(x)
plot(values, heightcdf(values), type="1",
xlab="a (Height in inches)", ylab = "Pr(x <= a)")
i have error; this " Error in plot.xy(xy, type, ...) : invalid plot type '1'"what can i do in this situation?
Hi, welcome to the forum.
I am not sure what you want to do with
heightcdf <- ecdf(x)
but it
> class(heightcdf)
heightcdf
Empirical CDF
Call: ecdf(x)
x[1:8] = 2, 3, 4, ..., 8, 9
> class(heightcdf)
[1] "ecdf" "stepfun" "function"
says it is not plotable.
1 Like
Something like this will give you a plot but i don't think it is what you intend.
library(UsingR)
x <- sample(2:10, 300 , replace = TRUE)
smallest <- floor(min(x))
largest <- ceiling(max(x))
values <- seq(smallest, largest, len = 300)
heightcdf <- ecdf(x)
myvals <- heightcdf(values)
plot(values, myvals,
xlab="a (Height in inches)", ylab = "Pr(x <= a)")
1 Like
system
Closed
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.