2

My aim is to generate a cumulative distribution function made with steps, using the parameter type="s", but when i try for example

plot(ecdf(rgeom(0:40,0.3)), type="s")

it says the error

Error in plot.default(NA, NA, type = "n", xlim = xlim, ylim = ylim, xlab = xlab,  : formal argument "type" matched by multiple actual arguments

What to do?

eipi10
  • 91,525
  • 24
  • 209
  • 285
Poli
  • 89
  • 1
  • 2
  • 8
  • `ecdf` has its own plotting method; see `?plot.ecdf`. Adjust as you like, e.g. `plot(ecdf(rgeom(0:40,0.3)), verticals = TRUE, pch = NA, col.01line = NA)` – alistaire Feb 06 '18 at 17:28
  • Try this `curve(ecdf(rgeom(0:40,0.3))(x), from = 0, to = 40, type = "s")` – rredondo Mar 06 '19 at 18:07

1 Answers1

3

Instead try:

plot(ecdf(rgeom(0:40,0.3)),verticals = TRUE)

In this case plot dispatches to plot.ecdf which in turn calls plot.stepfun. plot.stepfun initializes a plot using a call to plot() that specifies type = "n", hence the conflict in type arguments.

The verticals argument is from plot.ecdf and so it gets passed along happily without any conflicts.

joran
  • 169,992
  • 32
  • 429
  • 468
  • Ok so in which case can i use `type="n"` and for which kind of plots? – Poli Feb 06 '18 at 17:42
  • @Poli The only way to know for sure is to look carefully at the documentation & code for each `plot` method. – joran Feb 06 '18 at 18:45