Re: [R] Replace NAs in a range of data frame columns

2009-12-12 Thread David Winsemius
On Dec 12, 2009, at 6:15 PM, Patrizio Frederic wrote: hi Michael, the following code should work b <- a[match('first',names(a)): match('last',names(a))] b[is.na(b)]<-0 This might not throw an error: b <- apply(a[match('first',names(a)): match('last',names(a))], 1:2, fun

Re: [R] Replace NAs in a range of data frame columns

2009-12-12 Thread Patrizio Frederic
hi Michael, the following code should work b <- a[match('first',names(a)): match('last',names(a))] b[is.na(b)]<-0 a[match('first',names(a)): match('last',names(a))] <- b cheers, Patrizio 2009/12/13 Michael Scharkow : > Dear all, > > I'm stuck in a seemingly trivial task that I need to perform f