An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20051027/a9a54d05/attachment.pl
adding sequence for each value in a vector
3 messages · Yves Magliulo, Gabor Grothendieck, Romain Francois
On 27 Oct 2005 17:04:21 +0200, Yves Magliulo <ym at climpact.com> wrote:
hi, i have a vector like : x<-c(1,15,30,45,60,90,115) i know that step by step i have always more than 10 min(diff(x)) >=11 i want to add for each value a sequence of value:value+9 result should be : 1 2 3 4 5 6 7 8 9 10 15 16 17 18 19 20 21 22 23 24 30 31 (...) 39 45 46 (...) 54 60 61 etc.. how can i do this without a loop (i'm sure there is a "elegant" way like always with R but i can't find it this time!)
Try this: c(outer(0:9, x, "+"))
Le 27.10.2005 17:04, Yves Magliulo a ??crit :
hi, i have a vector like : x<-c(1,15,30,45,60,90,115) i know that step by step i have always more than 10 min(diff(x)) >=11 i want to add for each value a sequence of value:value+9 result should be : 1 2 3 4 5 6 7 8 9 10 15 16 17 18 19 20 21 22 23 24 30 31 (...) 39 45 46 (...) 54 60 61 etc.. how can i do this without a loop (i'm sure there is a "elegant" way like always with R but i can't find it this time!) best, yves
Also : R> rep(x, each=10) + 0:9
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques +---------------------------------------------------------------+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---------------------------------------------------------------+