replacement

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

replacement

Samor Gandhi
Hi, Is it possible to do the following
 
> mydata
   y    x
1  0.3  1
2  0.8  NA
3  NA   0
4  0.2  1
 
I would like to solve
 
 mydata <- replace(mydata, NA, NaN)
 
Thanks!
 __________________________________________________



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: replacement

Uwe Ligges
mydata[is.na(mydata)] <- NaN

Uwe Ligges


Samor Gandhi wrote:

> Hi, Is it possible to do the following
>  
>> mydata
>    y    x
> 1  0.3  1
> 2  0.8  NA
> 3  NA   0
> 4  0.2  1
>  
> I would like to solve
>  
>  mydata <- replace(mydata, NA, NaN)
>  
> Thanks!
>  __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: replacement

John Kane-2
In reply to this post by Samor Gandhi

mydata[is.na(mydata)]  <-  NaN

should work

--- Samor Gandhi <[hidden email]> wrote:

> Hi, Is it possible to do the following
>  
> > mydata
>    y    x
> 1  0.3  1
> 2  0.8  NA
> 3  NA   0
> 4  0.2  1
>  
> I would like to solve
>  
>  mydata <- replace(mydata, NA, NaN)
>  
> Thanks!

______________________________________________
[hidden email] 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.