One way:

x<-c(1,3,-1,0,4)
> x[x>0]<-NA
> x
[1] NA NA -1  0 NA
>

bob


-----Original Message-----
From: Yulei He [mailto:yuleih@umich.edu] 
Sent: Monday, October 27, 2003 4:05 PM
To: r-help@stat.math.ethz.ch
Subject: [R] how to set missing values in R

Hi, there.

Can I ask how to set up missing values in R? Suppose I want to assign the
missing value to the elements in vector which is greater than zero like
this:

x<-c(1,3,-1,0,4);

after the missing value assignment, x becomes (NA,NA,-1,0,NA).

Thanks!

Yulei


$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Yulei He
1586 Murfin Ave. Apt 37
Ann Arbor, MI 48105-3135
yuleih@umich.edu
734-647-0305(H)
734-763-0421(O)
734-763-0427(O)
734-764-8263(fax)
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

	[[alternative HTML version deleted]]


