Re: [R] manipulating arrays

2007-07-30 Thread Peter Dalgaard
Henrique Dallazuanna wrote: > Hi, I don't know if is the more elegant way, but: > > X<-c(1,2,3,4,5) > X <- c(X[1], 0, X[2:5]) > append(X, 0, 1) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the po

Re: [R] manipulating arrays

2007-07-30 Thread Stephen Tucker
I think you are looking for append(), though it won't modify the object in-place like Python [I believe that is a product of R's 'functional programming' philosophy]. might want to check this entertaining thread: http://tolstoy.newcastle.edu.au/R/help/04/11/7727.html in this example it would be l

Re: [R] manipulating arrays

2007-07-30 Thread Gabor Grothendieck
Try this: > x <- 11:15 > append(x, values = 99, after = 1) [1] 11 99 12 13 14 15 On 7/27/07, Nair, Murlidharan T <[EMAIL PROTECTED]> wrote: > Can I insert an element in an array at a particular position without > destroying the already existing element? > > > > X<-c(1,2,3,4,5) > > > > I want to

Re: [R] manipulating arrays

2007-07-30 Thread Rolf Turner
?append cheers, Rolf Turner On 28/07/2007, at 2:12 AM, Henrique Dallazuanna wrote: > Hi, I don't know if is the more elegant way, but: > > X<-c(1,2,3,4,5) > X <- c(X[1], 0, X[2:5]) > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O >

Re: [R] manipulating arrays

2007-07-27 Thread Henrique Dallazuanna
Hi, I don't know if is the more elegant way, but: X<-c(1,2,3,4,5) X <- c(X[1], 0, X[2:5]) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 27/07/07, Nair, Murlidharan T <[EMAIL PROTECTED]> wrote: > > Can I insert an element in an array at a particular position with

[R] manipulating arrays

2007-07-27 Thread Nair, Murlidharan T
Can I insert an element in an array at a particular position without destroying the already existing element? X<-c(1,2,3,4,5) I want to insert an element between 1 and 2. Thanks ../Murli [[alternative HTML version deleted]] __ R