[R] replaces a matrix of "NA"s in an array with the previous matrix with numbers

2010-10-06 Thread Farida Mostajabi
Dear list, Does anyone know if there is a function that replaces a matrix of "NA"s in an array with the previous matrix with numbers? For example, I have an array ab <- array(dim=c(3,3,15),dimnames=list(rows=1:3,cols=1:3,dim=times)) . Select out put from the array is: , , dim = 0.4783569695577

Re: [R] Removing replicated rows

2009-12-30 Thread Farida Mostajabi
It worked perfectly. Thank you! On Wed, Dec 30, 2009 at 12:21 PM, Henrique Dallazuanna wrote: > Try this: > > unique(x)[rep(1:nrow(unique(x)), m),] > > > On Wed, Dec 30, 2009 at 2:35 PM, wrote: > > Dear All, > > > > I have a matrix like X and need to create a new matrix based on the > vector >

Re: [R] apply a function over a factor

2009-12-29 Thread Farida Mostajabi
Thanks! That's what I need. On Tue, Dec 29, 2009 at 1:33 PM, Dimitris Rizopoulos < d.rizopou...@erasmusmc.nl> wrote: > have a look at ?ave(), e.g., > > A <- 1:10 > B <- factor(c(1,2,2,4,4,4,7,7,7,7)) > > ave(A, B) > > > I hope it helps. > > Best, > Dimitris > > > farida...@gmail.com wrote: > >> D

Re: [R] Replace values in a vector

2009-12-03 Thread Farida Mostajabi
Yes, should be 6 0.2. The code worked. Thank you! >>> William Dunlap 12/03/09 12:07 PM >>> > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Farida Mostajabi > Sent: Thursday, December 0

Re: [R] Replace values in a vector

2009-12-03 Thread Farida Mostajabi
hu, Dec 3, 2009 at 11:41 AM, Farida Mostajabi wrote: > Hi all, > > I have a vector like this: > > x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8) > > I would like to replace the zero values with the first previous non zero > value. > > my returni

[R] Replace values in a vector

2009-12-03 Thread Farida Mostajabi
Hi all, I have a vector like this: x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8) I would like to replace the zero values with the first previous non zero value. my returning vector should look like this: y<-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8) How can I do