search for: varvendas

Displaying 1 result from an estimated 1 matches for "varvendas".

2009 Jun 08
5
if else
...ame dataframe with a variable X3 that is: X1, if X2=NA X2, if X1=NA X1+X2 if X1 and X2 are not NA So my final data is X3<-c(15,NA,12,5,10,2,15,NA,12,5,10,2) finaldata<-data.frame(firm, year,X1,X2,X3) I've tried this finaldata<-ifelse(data$X1==NA,ifelse(data$X2==NA,NA,X2),ifelse(data$varvendas==NA,X1,X1+X2)) But I got just NA in X3. Anyone could help me with this? Thanks in advance, Cec?lia (Universidade de Aveiro - Portugal)