Wants to create a new variable by one variable minus another one, but don't know what function can be used. I know rowSums can be used to do addition, for example:
new variable value= Sleep + Dream
data(sleep) # use built-in data from package VIM
test["NewVar"]<- rowSums(test[c(4,5)], na.rm=TRUE)
if wants to assign value by 5 minus 4 to new variable (NewVar=Sleep - Dream), how to do that? is there a specific function to do subtraction calculation? since data including missing value, have to use function with a option na.rm=T.