Re: [R] Changing multiple instances in data.frame

2012-03-30 Thread Trevor Davies
If I could add one comment, the above solution leaves NAs if you are not changing the names of all of the variables (those not present are assigned NA's). The solution for this is of course: df1 <- data.frame(V1=1:3,V2=c(paste(LETTERS[1],LETTERS[1:3],sep='')),stringsAsFactors = FALSE) unique(df1$

Re: [R] Changing multiple instances in data.frame

2012-03-28 Thread David Winsemius
On Mar 28, 2012, at 6:40 PM, Trevor Davies wrote: Thank you, works perfectly. Good. There is also a recode function in package 'car' (IIRC) which attempts to replicate the syntax of the same command in SPSS. But once I figured out how to use match() as an index with "[", I have never n

Re: [R] Changing multiple instances in data.frame

2012-03-28 Thread Trevor Davies
Thank you, works perfectly. On Wed, Mar 28, 2012 at 3:11 PM, David Winsemius wrote: > > On Mar 28, 2012, at 5:26 PM, Trevor Davies wrote: > > I've looked but I cannot find a more elegant solution. >> >> I would like to be able to scan through a data.frame and remove multiple >> and various insta

Re: [R] Changing multiple instances in data.frame

2012-03-28 Thread David Winsemius
On Mar 28, 2012, at 5:26 PM, Trevor Davies wrote: I've looked but I cannot find a more elegant solution. I would like to be able to scan through a data.frame and remove multiple and various instances of certain contents. A trivial example is below. It works, it just seems like there sho

[R] Changing multiple instances in data.frame

2012-03-28 Thread Trevor Davies
I've looked but I cannot find a more elegant solution. I would like to be able to scan through a data.frame and remove multiple and various instances of certain contents. A trivial example is below. It works, it just seems like there should be a one line solution. #Example data: a <- data.frame