I am trying to define a new variable that is the division of two other variables.
df$NewVariable <- df$OldVariable1 / (df$OldVariable2/100)
OldVariable2
contains NA
s. I'd like NewVariable
to return NA
s, whenever OldVariable2
is NA
. However, when I do summmary(df$NewVariable)
after creating it, I get average and maximum of Inf
. How can I tell R to produce NA
s, so that my new NewVariable
isn't affected by any Inf
s?