Re: [R] Modifying a data.frame

2010-10-03 Thread Jeffrey Spies
You should examine what is being looped over when you use a for loop with the "i in dataframe" syntax: j<-1; for(i in ex){ cat('step', j, i, sep=" ", fill=T); j<-j+1} As you can see, each column in ex is being set to i for each step of the for loop. Instead, it seems that you want to step over e

[R] Modifying a data.frame

2010-10-03 Thread Bapst Beat
Hello list members I have a problem with modifying a data.frame. As an example given is a data.frame called ex : ex<-data.frame(id=c(1,2,3,4,5,6),obs=c(14,9,20,36,55,47),eff=c("A","A","B","C","C","C")) After that I would like to modify the object ex with the following short script: for (i i