[R] assigning NA's

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Wed Jan 23 13:33:48 CET 2002



> -----Original Message-----
> From: Patrick Buetzberger [mailto:patrick at giub.unibe.ch]
> Sent: Tuesday, January 22, 2002 12:36 PM
> To: r-help at lists.R-project.org
> Subject: [R] assigning NA's
[...]

> I've tried to use the same command for assigning NA's to 
> missing values
> (=-999)  in each object created with above loop, like this:
> for(i in seq(1,nfn,1)){
>  assign(paste("f", i, sep = "")[paste("f", i, sep = "") < -500.], NA)
> }

Probably the simplest solution is to use a temporary object inside your
first loop and do the NA handling there.  Something like:

	for(i in seq(1,nfn,1)){
		fin<-
paste("/home/klimet/patrick/LAEGEREN/NEBEL/FOGEVENT2000/",fn[i],sep="")

	 	dat<- as.matrix(read.table(fin,skip=1))
		dat[dat< -500.] <- NA

		assign(paste("f", i, sep = ""), dat)
	}
	

If you really need to keep the loops separate, you can use 'get' to grab the
contents of each object, make the substitution, and then use 'assign' again
to write it out:


	for(i in seq(1,nfn,1)){
	
	 	dat<- get( paste("f", i, sep = "") )
		dat[dat< -500.] <- NA
		assign(paste("f", i, sep = ""), dat)
	}

-Greg


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list