Home Aggregate and NA values
 This question already has an answer here: Calculate mean across rows with NA values in R 2 answers I've got a dataframe with 1000 observations. For each observation I got five variables. Now I'd like to create a new variable which is an aggregation from those 5 variables. I typed the following: df\$aggr_variable <- (1/5)*(var1+var2+var3+var4+var5)  I then got the new aggregated variable, but also a problem. If let's say observation 839 got a missing value NA in var2, but still values for the other four variables, it gives me NA in the aggregated variable. How can I leave the NA's of the five variables out without having to leave out the whole observation when one variable contains an NA?