Sarada Samantaray
2015-Apr-13 13:33 UTC
[R] R (3.1.2) sub-setting code related to "NA" on Windows not working!
My AirQuality[4,1] is equal to 18 and AirQuality[5,1] is equal to NA. When I type the following> is.na(AirQuality[5,1])[1] FALSE> AirQuality[5,1][1] NA68 Levels: 1 10 108 11 110 115 118 12 122 13 135 ... NA> is.na(AirQuality[4,1])[1] FALSE> AirQuality[4,1][1] 1868 Levels: 1 10 108 11 110 115 118 12 122 13 135 ... NA>For is.na(AirQuality[5,1]) I am expecting a TRUE (but False is the output from R). Can you please help. Or Let me know what I am doing wrong! RegardsSarada [[alternative HTML version deleted]]
peter dalgaard
2015-Apr-13 15:32 UTC
[R] R (3.1.2) sub-setting code related to "NA" on Windows not working!
This is almost unreadable due to HTML posting (do read the posting guide!). However, it would seem that you somehow got your data converted to factors of which one level is NA. This may be surprising, but the difference is like that of> factor(c("NA", 18))[1] NA 18 Levels: 18 NA> factor(c("NA", 18), exclude="NA")[1] <NA> 18 Levels: 18 Notice that NA can be a real factor level, for instance abbreviating "North America" or "Noradrenaline". It is fairly easy to generate this situation during data input, e.g.> read.table(text="+ NA + 18", na.strings="")$V1 [1] NA 18 Levels: 18 NA -pd On 13 Apr 2015, at 15:33 , Sarada Samantaray <sarada at greenhorizon.in> wrote:> My AirQuality[4,1] is equal to 18 and AirQuality[5,1] is equal to NA. > When I type the following >> is.na(AirQuality[5,1])[1] FALSE> AirQuality[5,1][1] NA68 Levels: 1 10 108 11 110 115 118 12 122 13 135 ... NA> is.na(AirQuality[4,1])[1] FALSE> AirQuality[4,1][1] 1868 Levels: 1 10 108 11 110 115 118 12 122 13 135 ... NA> > For is.na(AirQuality[5,1]) I am expecting a TRUE (but False is the output from R). Can you please help. Or Let me know what I am doing wrong! > RegardsSarada > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
John Kane
2015-Apr-13 15:43 UTC
[R] R (3.1.2) sub-setting code related to "NA" on Windows not working!
Below is what your code looked like in R-helpl. I looked at it for about 5 seconds and said, "If the poster cannot understand something as simple as "DO NOT post in HTML" it's not worth my time to decypher the mess. You are lucky Peter is more tolerant. Please do not post in HTML. #### code as it appears in R-help My AirQuality[4,1] is equal to 18 and AirQuality[5,1] is equal to NA. When I type the following > is.na(AirQuality[5,1])[1] FALSE> AirQuality[5,1][1] NA68 Levels: 1 10 108 11 110 115 118 > 12 122 13 135 ... NA> is.na(AirQuality[4,1])[1] FALSE> AirQuality[4,1][1] 1868 Levels: 1 > 10 108 11 110 115 118 12 122 13 135 ... NA> ####=========== John Kane Kingston ON Canada> -----Original Message----- > From: sarada at greenhorizon.in > Sent: Mon, 13 Apr 2015 06:33:19 -0700 > To: r-help at r-project.org > Subject: [R] R (3.1.2) sub-setting code related to "NA" on Windows not > working! > > My AirQuality[4,1] is equal to 18 and AirQuality[5,1] is equal to NA. > When I type the following >> is.na(AirQuality[5,1])[1] FALSE> AirQuality[5,1][1] NA68 Levels: 1 10 >> 108 11 110 115 118 12 122 13 135 ... NA> is.na(AirQuality[4,1])[1] >> FALSE> AirQuality[4,1][1] 1868 Levels: 1 10 108 11 110 115 118 12 122 13 >> 135 ... NA> > For is.na(AirQuality[5,1]) I am expecting a TRUE (but False is the output > from R). Can you please help. Or Let me know what I am doing wrong! > RegardsSarada > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.____________________________________________________________ Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords & protects your account.