Hi Georg, You could just use this: Umsatz_2011<-c(1,2,3,4,5,NA,7,8,NA,10) Kunde_2011<-rep(0:1,5) Check_Kunde_2011<- c("OK","Check")[as.numeric(is.na(Umsatz_2011) & Kunde_2011 == 1)+1]
Check_Kunde_2011 will be a vector of strings. Jim On Tue, Apr 26, 2016 at 6:09 PM, <g.maub...@weinwolf.de> wrote: > Hi All, > > I need to evaluate missing values in my data. I am able to filter these > values and do simple statistics on it. But I do need new variables based > on variables with missing values in my dataset: > > Check_Kunde_2011 <- ifelse(is.na(Umsatz_2011) == TRUE & Kunde_2011 == 1, > 1, 0) > Check_Kunde_2011 <- factor(Check_Kunde_2011, levels = c(1,0), labels = > c("Check", "OK")) > > The new variable is not correctly created. It contains no values: > > table(Check_Kunde_2011) > < table of extent 0 > > > I searched the web but could not find a solution. > > How can I work with variables and missing values in logical expressions? > > Where could I find something about this? > > Kind regards > > Georg > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.