1
xs <- seq(floor(min(fheight)),ceiling(max(fheight)),0.01)
plot(xs, ecdf(fheight)(xs),type = "l", xlab = "height in inches",ylab = "F(x)")

What is the purpose of (xs) in ecdf(fheight)(xs)

MLavoie
  • 8,799
  • 39
  • 36
  • 51

1 Answers1

1

ecdf(fheight) returns a function. Yes, it's a bit odd having a function that takes arguments to return another function.

xs are the arguments to the resulting function.

So ecdf(fheight)(xs) will return the values of the cumulative density function ecdf(fheight) at the values of xs.

From the R help available from ?ecdf you can see this:

Value

For ecdf, a function of class "ecdf"

QuishSwash
  • 2,507
  • 2
  • 24
  • 45