[R] Replace / swap values of subset of a data.frame

Gabor Grothendieck ggrothendieck at gmail.com
Wed May 20 05:10:25 CEST 2009


If DF is your data frame:

DF2 <- edit(DF)

and then make the changes manually in the spreadsheet that
pops up.

On Tue, May 19, 2009 at 3:50 PM, tsunhin wong <thjwong at gmail.com> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list