Are you sure it doesn't? na.rm=T works for me, so I think your problem is
elsewhere.

Specifically, the example given below consists of 27 character strings, not
numbers, so there' so surprise R doesn't want to give you a mean -- to R,
it's as logical as asking for the average of "a" and "Q5"

Try this:

mean(as.double(Tout),na.rm=T)

I get -11.048 with a warning message saying that some NA's were created in
trying to coerce ". " to a double.

Alternatively, if you didn't actually mean all those "" marks below (in
which case I don't know what ". " is in R), try this: mean(Tout[Tout != ".
"]), but again -- that's likely not your problem.

Michael Weylandt

On Tue, Aug 2, 2011 at 5:47 PM, Jeffrey Joh <johjeff...@hotmail.com> wrote:

>
> I have the following:
>
> Tout = c(".    ", ".    ",
> + "-51.0", " -9.6", " -9.6", " -9.6", " -9.6", " -9.6", " -9.6",
> + " -9.6", " -9.5", " -9.5", " -9.6", " -9.5", " -9.6", " -9.6",
> + " -9.5", " -9.4", " -9.3", " -9.3", " -9.3", " -9.2", " -9.0",
> + " -9.0", " -8.9", " -8.9", " -8.9")
>
>
>
> How can I take the mean while ignoring the null values?  I don't want to
> delete the ".    ", just ignore.  na.rm=TRUE does not work for this.
>
>
> Jeffrey
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to