Re: [R] Fill in NA values in vector with previous character/factor

2008-07-28 Thread Christos Hatzis
Suite 5350 Woburn, MA 01801 Tel: 781-938-3830 www.nuverabio.com > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Bert Gunter > Sent: Monday, July 28, 2008 4:05 PM > To: 'Dimitris Rizopoulos'; 'Owen Jones' > Cc

Re: [R] Fill in NA values in vector with previous character/factor

2008-07-28 Thread Bert Gunter
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dimitris Rizopoulos Sent: Monday, July 28, 2008 12:26 PM To: Owen Jones Cc: r-help@r-project.org Subject: Re: [R] Fill in NA values in vector with previous character/factor try function na.locf() from package 'zoo', i.e., library(zoo) x

Re: [R] Fill in NA values in vector with previous character/factor

2008-07-28 Thread Yasir Kaheil
maybe this is easiest way to do it: x<-c("A","B",NA,NA,"C",NA,NA,NA,NA,"D",NA,NA); x[is.na(x)]<- "D"; x thanks y Owen Jones-3 wrote: > > I have a vector of data (species names) interspersed with NA values > and I want a function to "fill in the blanks", replacing NA values > with wha

Re: [R] Fill in NA values in vector with previous character/factor

2008-07-28 Thread Dimitris Rizopoulos
try function na.locf() from package 'zoo', i.e., library(zoo) x <- c("A","B",NA,NA,"C",NA,NA,NA,NA,"D",NA,NA) na.locf(x) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, B

Re: [R] Fill in NA values in vector with previous character/factor

2008-07-28 Thread Gabor Grothendieck
Try this: library(zoo) x <- c("A","B",NA,NA,"C",NA,NA,NA,NA,"D",NA,NA) na.locf(x) On Mon, Jul 28, 2008 at 2:10 PM, Owen Jones <[EMAIL PROTECTED]> wrote: > I have a vector of data (species names) interspersed with NA values and I > want a function to "fill in the blanks", replacing NA values wi