I'm trying to see if R has a command similar to Stata. In Stata, the !mi(a, b, c,...) command creates a new variable and indicates a 1/0 if the indicated variable(s) have no missing data. 1 = no missing data across variables x, 0 = missing data in one of the variables x.
I'm looking for a simple code because sometimes I have about 15-20 variables (mainly to mark listwise deletion cases). It takes a little more work but I specify the column names instead of using the : marker. The options I've found creates a new dataframe (na.omit), but I want to retain all the cases.
I know that ifelse can accomplish this using:
df$test <- ifelse(!is.na(df$ID) & !is.na(df$STATUS), 1,0)
I like to know if there's another way with less code where I don't need to write "!is.na(df$ )" over and over. Maybe a $global code (similar to Stata)?