table, data.frame.
Which has 12 columns with variable names and 24 rows df
Like:
Var1 Var2 Var3 Var4 Var12
1 NA 2 3 4
5 6 2 3 3
NA 7 8 NA 4
And I want to calculate the mean for each column while ignoring the Na's For example:
colMeans(df)
And get the result like:
Var1 Var2 Var3 Var4 Var12
3 6,5 4 3 3,66
I don't want the NA
's to be considered in the calculation of Mean.
I tried some methods like na.omit
, !is.na
, but I don't get the desired result like what I described above.