On Mon, 12-Sep-2011 at 12:35PM -0700, holly shakya wrote:
|> I have 2 columns for weight. There are NAs in each column but not for the
|> same observation. Some observations have values for both. I would want to
|> prioritize the WT2 values so I would like to do the following:
|>
|> >From this:
You can do this using ifelse(). See example below.
x<-rpois(100,100)
NA.x<-sample(1:100,40)
x[NA.x]=NA
y<-rpois(100,100)
NA.y<-sample(1:100,40)
y[NA.y]=NA
z<-ifelse(!is.na(y),y,ifelse(!is.na(x),x,NA))
HTH,
Daniel
holly shakya wrote:
>
> I have 2 columns for weight. There are NAs in each col
I have 2 columns for weight. There are NAs in each column but not for the
same observation. Some observations have values for both. I would want to
prioritize the WT2 values so I would like to do the following:
>From this:
ID WT1WT2
1 134 NA
2 145 155
1
3 matches
Mail list logo