[R] seq: specify *minimum* end value, more elegant solution

Henrique Dallazuanna wwwhsd at gmail.com
Mon Aug 18 21:07:09 CEST 2008


Hi,

Maybe you can specify the length of vector:

seq(from=0, by=4, l = 4)
seq(from=0, by=4, l = 5)



On Mon, Aug 18, 2008 at 3:38 PM, Timothy W. Hilton <twh142 at psu.edu> wrote:
> Hello,
>
> Using seq, I would like to specify a minumum end value, rather than a maximum end value.  For example, rather than
>
>> seq(from=0, to=10, by=4)
> [1] 0 4 8
>
> I would like to obtain
> [1] 0 4 8 12
>
> I can do that with
>> by.value = 4
>> seq(from=0,by=by.value,to=ceiling(10 / by.value)*by.value)
> [1]  0  4  8 12
>
> That seems like a somewhat clunky solution, though, and requires an additional variable (by.value) that shows up three times.  Is there a more elegant solution to this?
>
> Thanks!
> Tim
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list