From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>

Date: Sat 25 Jun 2005 - 03:01:30 EST

Date: Sat 25 Jun 2005 - 03:01:30 EST

Omar Lakkis <uofiowa@gmail.com> 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 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Sat Jun 25 03:06:58 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:33:02 EST
*