Timothy W. Hilton
2008-Aug-18 18:38 UTC
[R] seq: specify *minimum* end value, more elegant solution
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
Henrique Dallazuanna
2008-Aug-18 19:07 UTC
[R] seq: specify *minimum* end value, more elegant solution
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