Re: [R] NA values

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Mon 12 Jun 2006 - 23:04:57 EST


Hi

yes, but I ****do not**** recommend you to do it

> df<-data.frame(a=1:10, b=11:20)
> df[5,2]<-NA
> df

    a b
1 1 11
2 2 12
3 3 13
4 4 14
5 5 NA
6 6 16
7 7 17
8 8 18
9 9 19
10 10 20
> df[is.na(df)]<-1000
> df

    a b
1 1 11
2 2 12
3 3 13
4 4 14
5 5 1000
6 6 16
7 7 17
8 8 18
9 9 19
10 10 20
>

but in that case you can not simply compute means, sums and other values just by e.g.

colSums(df, na.rm=T)

HTH
Petr

On 12 Jun 2006 at 18:18, Arun Kumar Saha wrote:

Date sent:      	Mon, 12 Jun 2006 18:18:33 +0530
From:           	"Arun Kumar Saha" <arun.kumar.saha@gmail.com>
To:             	"r-help@stat.math.ethz.ch" <R-help@stat.math.ethz.ch>
Subject:        	[R] NA values

> Dear all R users,
>
> I am wondering whether there is any way to replace all "NA" values in
> a data frame by some numerical value, suppose 1000?
>
> Thanks and Regards
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 13 02:42:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 13 Jun 2006 - 04:12:59 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.