On 05-10-2012, at 11:27, fxen3k wrote: > Hi all, > > I recently tried to calculate the mean and the median just for one column. > In this column I have numbers with some empty cells due to missing data. > So how can I calculate the mean just for the filled cells? > I tried: > mean(dataSet2$ac_60d_4d_after_ann[!is.na(master$ac_60d_4d_after_ann)], > na.rm=TRUE) > But the output was different to the calculation I died in Microsoft Excel. >
No data ==> no can answer question. What did you expect? What did Excel give you? But you are trying to calculate the mean of dataSet2$ac_60d_4d_after_ann and indexing with the indices of non-NA numbers of master$ac_60d_4d_after_ann. mean(dataSet2$ac_60d_4d_after_ann, na.rm=TRUE) should do what you want. Berend ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.