[R] Multiple missing values
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Feb 14 16:11:54 CET 2010
NA, Inf, -Inf, NaN would give you 4 possibilities and is.finite would
check if its any of them:
> x <- c(1, NA, 2, Inf, 3, -Inf, 4, NaN, 5)
> is.finite(x)
[1] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE
You might need to map them all to NA before using it with various
functions depending on how the functions deal with these values.
Other possibilities are to have an attribute with a factor defining
the type of each NA.
x <- c(1, NA, 2, NA, 3, NA)
attr(x, "type.of.na") <- factor(c("A", "B", "A"))
and depending on how much work you are prepared to do you could define
a new R class that handles objects with such an attribute.
On Sun, Feb 14, 2010 at 9:33 AM, John <john.macinnes at ed.ac.uk> wrote:
> Does anyone know, or know documentation that describes, how to declare
> multiple values in R as missing that does not involve coding them as NA? I
> wish to be able to treate values as missing, while still retaining codes
> that describe the reason for the value being missing.
>
> Thanks
>
> John MAcInnes
>
>
> --
> Professor John MacInnes
> Sociology,
> School of Social and Political Studies,
> No 8 Buccleuch Place
> University of Edinburgh
> Edinburgh EH8 9LN
> +44 (0)131 651 3867
>
> Centre d'Estudis Demogràfics
> Universitat Autònoma de Barcelona
> Edifici E-2
> 08193 Bellaterra (Barcelona)
> Spain
> +34 93 581 3060
> "The University of Edinburgh is a charitable body, registered in Scotland,
> with registration number SC005336."
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>
More information about the R-help
mailing list