merge - Merging two columns into one in R -
i have following data frame, , trying merge 2 columns one, while replacing na
's numeric values.
id b 1 3 na 2 na 2 3 na 4 4 1 na
the result want is:
id new 1 3 2 2 3 4 4 1
thanks in advance!
you can do: with(d,ifelse(is.na(a),b,a))
where d
data frame.
Comments
Post a Comment