[R] Calculating the mean in one column with empty cells
katakagi at bu.edu
Fri Oct 5 15:04:19 CEST 2012
fxen3k <f.sehardt <at> gmail.com> writes:
> 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:
> But the output was different to the calculation I died in Microsoft Excel.
> Thanks in advance,
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
Assuming that you have the data frame formatted properly, mean(yourdata$column,
na.rm = T) should work. When coverting an excel table to R, I usually fill in
blank cells with NA before importing. If you try to import an data frame with
empty cells, you usually get an error using read.table(). But since you seem to
have already got you data into R, that may not be the problem.
More information about the R-help