Hello everybody!
I have 2 >issues< concerning methods applied to missing data.
I think they're bugs, but who knows.
1. var(NA) returns
Error in var(NA) : missing observations in cov/cor
instead of NA. I expanded the summary-function to my.summary
including SDev, in order to use it with tapply, which crashes
in case of groups with no valid data.
2. is a similar problem. I use tapply with hist. On groups
without valid data it crashes, like hist(as.numeric(c(NA)))
returning
Error in pretty(rx, n = nnb, min.n = 1) : x must be numeric
hist(as.numeric(c(NA)),breaks=c(1,2)) works, as it does not use "pretty".
I know these are very special cases, but unfortunately they kill the whole
process.
I can figure out some personal solution, but I hope for a professional one.
Hope this is kind of helpful.
Maciej
sysname "Linux"
release "2.4.4"
version "#1 SMP Wed May 2 20:47:43 CEST 2001"
nodename "lxnf"
machine "i686"
login "unknown"
user "hoffman"
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
methods on missing data
4 messages · Maciej.Hoffman-Wecker@evotecoai.com, Thomas Lumley, Achim Zeileis +1 more
On Wed, 6 Jun 2001 Maciej.Hoffman-Wecker at evotecoai.com wrote:
Hello everybody!
I have 2 >issues< concerning methods applied to missing data.
I think they're bugs, but who knows.
1. var(NA) returns
Error in var(NA) : missing observations in cov/cor
instead of NA. I expanded the summary-function to my.summary
including SDev, in order to use it with tapply, which crashes
in case of groups with no valid data.
var() already has a na.rm option that does what you want R> var(NA,na.rm=TRUE) [1] NA
2. is a similar problem. I use tapply with hist. On groups
without valid data it crashes, like hist(as.numeric(c(NA)))
returning
Error in pretty(rx, n = nnb, min.n = 1) : x must be numeric
hist(as.numeric(c(NA)),breaks=c(1,2)) works, as it does not use "pretty".
I know these are very special cases, but unfortunately they kill the whole
process.
try() is a general solution to the problem of functions that must sometimes be applied to invalid data without causing an error. Unlike the var(NA) case, hist(NA) can't really do anything useful so try() is a reasonable solution. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Maciej.Hoffman-Wecker at evotecoai.com wrote:
Hello everybody! I have 2 >issues< concerning methods applied to missing data. I think they're bugs, but who knows.
I don't think so :-)
1. var(NA) returns
Error in var(NA) : missing observations in cov/cor
instead of NA.
Because you didn't tell var() that it should remove missing values, it warns you that there are missing values. If you want to remove them the following gives the answer you expected.
var(NA, na.rm=TRUE)
[1] NA
I expanded the summary-function to my.summary
including SDev, in order to use it with tapply, which crashes
in case of groups with no valid data.
2. is a similar problem. I use tapply with hist. On groups
without valid data it crashes, like hist(as.numeric(c(NA)))
returning
Error in pretty(rx, n = nnb, min.n = 1) : x must be numeric
hist(as.numeric(c(NA)),breaks=c(1,2)) works, as it does not use "pretty".
I know these are very special cases, but unfortunately they kill the whole
process.
Maybe you should check before if your vector contains only NA's, e.g., using is.na() Hope this helps Achim --------------------------- Achim Zeileis Institut f?r Statistik Technische Universit?t Wien -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 6 Jun 2001 Maciej.Hoffman-Wecker at evotecoai.com wrote:
I have 2 >issues< concerning methods applied to missing data.
I think they're bugs, but who knows.
1. var(NA) returns
Error in var(NA) : missing observations in cov/cor
It works exactly as documented: see ?var. Did you intend to use
var(NA, na.rm=T)
[1] NA ? I suspect so, so the bug does not seem to be in R....
instead of NA. I expanded the summary-function to my.summary
including SDev, in order to use it with tapply, which crashes
in case of groups with no valid data.
2. is a similar problem. I use tapply with hist. On groups
without valid data it crashes, like hist(as.numeric(c(NA)))
returning
Error in pretty(rx, n = nnb, min.n = 1) : x must be numeric
hist(as.numeric(c(NA)),breaks=c(1,2)) works, as it does not use "pretty".
I know these are very special cases, but unfortunately they kill the whole
process.
I can figure out some personal solution, but I hope for a professional one.
Hope this is kind of helpful.
Maciej
sysname "Linux"
release "2.4.4"
version "#1 SMP Wed May 2 20:47:43 CEST 2001"
nodename "lxnf"
machine "i686"
login "unknown"
user "hoffman"
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._