Re: [R] Problems with na.rm=T

From: Barry Rowlingson <b.rowlingson_at_lancaster.ac.uk>
Date: Thu, 14 Jun 2007 16:13:19 +0100

Lucke, Joseph F wrote:
> Suddenly (e.g. yesterday) all my functions that have "na.rm=" as a
> parameter (e.g., mean(), sd(), range(), etc.) have been reporting
> warnings with "na.rm=T". The message is "Warning message: the condition
> has length > 1 and only the first element will be used in: if (na.rm) x
> <- x[!is.na(x)] ". This has never happened before. I don't recall
> having done anything that might generate this message. How do I fix

  Do you have something called 'T':

 > T=c(1,2,3,4)
 > mean(x,na.rm=T)
[1] 2
Warning message:
the condition has length > 1 and only the first element will be used in: if (na.rm) x <- x[!is.na(x)]

  You should always use 'TRUE' for true and 'FALSE' for false. R makes it harder to shoot yourself in the foot that way:

 > TRUE=c(1,2,3)
Error in TRUE = c(1, 2, 3) : invalid (do_set) left-hand side to assignment

help(TRUE) helps:

Details:

      'TRUE' and 'FALSE' are part of the R language, where 'T' and 'F'
      are global variables set to these. All four are 'logical(1)'
      vectors.

Barry



R-help_at_stat.math.ethz.ch 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. Received on Thu 14 Jun 2007 - 15:53:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 16:31:56 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.