Possible Duplicate:
Combining two vectors element-by-element
I have two vectors
d = c(1, 2, NA, NA)
c = c(NA, NA, 1, NA)
How can I get an output that would combine the non NAs as follows?
[1] 1 2 1 NA
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you are asking is a bit vague. For example, what happens if you neither element is a NA?
Anyway, here’s one method that gives the desired result:
Which gives: