Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"type" not working in R plot function with ecdf object

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?

like image 258
Poli Avatar asked Jun 01 '26 16:06

Poli


1 Answers

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.

like image 53
joran Avatar answered Jun 03 '26 05:06

joran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!