Omar Lakkis <[EMAIL PROTECTED]> writes: > I want to generate a sequence from 1 to x by 1 > seq(1,x,by=1) > I want the above to return an empty list if x is zero > In other languages I can do 1:x:1 to force the increment by to be a > positive 1. This syntax does not work in R. In R 1:x gives me > 1 0 > when x is zero, this is not what I want. > The seq statement above throws an error when x is 0. > How can I generate a sequence where if the "to" value is less than the > "from" value an empty list is generated with no errors?
Provide a length argument. In your case, seq(length=x) should suffice. -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
