Skip to content
Back to formatted view

Raw Message

Message-ID: <1021538.1630610456@apollo2.minshall.org>
Date: 2021-09-02T19:20:56Z
From: Greg Minshall
Subject: How to globally convert NaN to NA in dataframe?
In-Reply-To: Your message of "Thu, 02 Sep 2021 10:17:31 -0400." <CAPcHnpTtapJMLwv0Q-W1w8zzynthrC+myJO1zWiARAo8gbiyKw@mail.gmail.com>

Andrew,

> x[] <- lapply(x, function(xx) {
>     xx[is.nan(xx)] <- NA_real_
>     xx
> })
> 
> is different from
> 
> x <- lapply(x, function(xx) {
>     xx[is.nan(xx)] <- NA_real_
>     xx
> })

indeed, the two are different -- but some ignorance of mine is exposed.
i wonder, can you explain why the two are different?

is it because of (or, "is the clue...") this in the "Value:" section of
: ?"[<-.data.frame"
----
     For '[<-', '[[<-' and '$<-', a data frame.
----
?

cheers, Greg