Re: [R] changing the values in a list

2008-01-10 Thread dxc13
I will give it a try, thanks for your input! Peter McMahan wrote: > > > On Jan 10, 2008, at 9:48 PM, Peter McMahan wrote: > >> y <- matrix(rep(y,ncol(x)),nrow=nrow(y)) >> x[is.na(x)] <- y[is.na(x)] > > oops, i meant: > y <- matrix(rep(y,ncol(res)),nrow=nrow(y)) > res[is.na(res)] <- y[is.na(r

Re: [R] changing the values in a list

2008-01-10 Thread Peter McMahan
On Jan 10, 2008, at 9:48 PM, Peter McMahan wrote: > y <- matrix(rep(y,ncol(x)),nrow=nrow(y)) > x[is.na(x)] <- y[is.na(x)] oops, i meant: y <- matrix(rep(y,ncol(res)),nrow=nrow(y)) res[is.na(res)] <- y[is.na(res)] __ R-help@r-project.org mailing list h

Re: [R] changing the values in a list

2008-01-10 Thread Peter McMahan
try: res <- apply(res,2,function(x){x[is.na(x)] <- y[is.na(x)];x}) should work, though not the most efficient/elegant alternately: y <- matrix(rep(y,ncol(x)),nrow=nrow(y)) x[is.na(x)] <- y[is.na(x)] (also not the most efficient/elegant) On Jan 10, 2008, at 9:38 PM, dxc13 wrote: > > useR's, > >

[R] changing the values in a list

2008-01-10 Thread dxc13
useR's, Does anyone know of an efficient way to change the values in a list to different numbers stored in an object? For example, consider the following: y <- matrix(c(20, 13, 25, 10, 17), ncol = 1) > res [[1]] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [