Hi,
How could I ignore NA to calculate the mean of each column, instead of deleting the NA and compose a new data frame calculation. As the result, it seems not right. is it possible to ignore the NA in batch processing way, instad of one by one manually?Thank you in advance!
d1<-data.frame(c1=c(2,NA,3,4,5,6),C2=c(9,2,3,4,5,7),C3=c(3,4,NA,NA,6,2))
View(d1)
apply(d1,2,function(x) mean(x))
#> c1 C2 C3
#> NA 5 NA