[R] create sequence of numbers
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Fri Oct 22 12:05:39 CEST 2010
one way is to use the sign() function, e.g.,
a <- 2
b <- 3
seq(a, b, by = sign(b-a)*0.5)
a <- 3
b <- 2
seq(a, b, by = sign(b-a)*0.5)
I hope it helps.
Best,
Dimitris
On 10/22/2010 11:58 AM, Alaios wrote:
> Hello.
> I want to create some sequence of numbers . So far I used sequence which does
> not work always
>
> seq(CRagent[[1]]$xy[1],CRagent[[2]]$xy[1],by=0.01)
> Error in seq.default(CRagent[[1]]$xy[1], CRagent[[2]]$xy[1], by = 0.01) :
> wrong sign in 'by' argument
> Calls: seq -> seq.default
>
>
> if the parameters are in descending form.
>
>
> The ideal would be to be able to use seq like this
>
> seq(2,3,by=0.5) --> 2,2.5,3
> seq(3,2,by=0.5)-->3,2.5,2
>
> Could you please help me implement this?
>
> I wouldl ike to thank you in advance for your help
>
> Best Regards
> Alex
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/
More information about the R-help
mailing list