[R] lines.formula with subset

John Field JohnField at ozemail.com.au
Fri Nov 14 01:40:51 CET 2008


Dear list,

When I try to use lines.formula with subset and another argument I 
get an error.
e.g.

x<-1:5
y<-c(1,3,NA,2,5)
plot(y~x, type="n")  # set up frame
lines(y~x, subset=!is.na(y))  # works OK
lines(y~x, type="o", col="blue")  # works OK
# but
lines(y~x, subset=!is.na(y), col="red")  # gives an error:

Error in if (length(x) == l) x[s] else x : argument is of length zero

Why does this happen?

With thanks,
John

=========================
John Field Consulting Pty Ltd
10 High Street, Burnside SA 5066
Phone 08 8332 5294 or 0409 097 586
Fax   08 8332 1229
Email  JohnField at ozemail.com.au



More information about the R-help mailing list