[R] Replace individual values in a data frame with NA

Michael Kubovy kubovy at virginia.edu
Fri Feb 9 17:39:24 CET 2007


On Feb 9, 2007, at 11:10 AM, Jason Horn wrote:

> I'd like to replace a value in a data frame with an NA, but can't
> figure out how.
>
> For example, say you have
>
> a<-c(1,2,3,4)
> b<-c(5,6,7,8)
> data<-data.frame(a,b)
>
> Now, how would you set the third row of the second column ( data
> [[3,2]] ) to NA?

a<-c(1,2,3,4)
b<-c(5,6,7,8)
data<-data.frame(a,b)
data[3, 2] <- NA

?Extract
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766
WWW:    http://www.people.virginia.edu/~mk9y/



More information about the R-help mailing list