[R] Replace / swap values of subset of a data.frame
tsunhin wong
thjwong at gmail.com
Tue May 19 21:50:15 CEST 2009
Dear R users,
I have 1 data.frame of 1500x80 - data1. I found out that there are a
few cells of data that I have misplace, and I need to fix the ordering
of them.
In an attempt trying to swap column 22 & 23 of the Subject with
misplaced data, I did the following:
> data2 <- data1
> subset(data1,(Subject==25 & Session==1))[,22] <- subset(data2,(Subject==25 & Session==1))[,23]
> (error messages... "Could not find function "subset<-")
> subset(data1,(Subject==25 & Session==1))[,23] <- subset(data2,(Subject==25 & Session==1))[,22]
> (error messages... "Could not find function "subset<-")
Please, please point me to some ways to achieve the swapping.
Thanks a lot!
Cheers,
John
More information about the R-help
mailing list