Re: [R] Create New Column Inside Data Frame for Many Data Frames

2013-04-14 Thread arun
Hi,  lapply(LETTERS[1:2],function(x) {x1<-get(x); x1$Rate<- ROC(x1$population);x1}) #[[1]]  # population   Rate #1    100 NA #2    300  1.0986123 #3   5000  2.8134107 #4   2000 -0.9162907 #5    900 -0.7985077 #6   2500  1.0216512 #[[2]]  # population   Rate

Re: [R] Create New Column Inside Data Frame for Many Data Frames

2013-04-14 Thread Jeff Newmiller
I suggest you read the section on indexing in the Introduction to R document that comes with R. In particular, look at the [[i]] notation. This comes in handy in a couple of ways. First, you shouldn't be working with "many" data frames at once that are stored as separately-named objects. If you

Re: [R] Create New Column Inside Data Frame for Many Data Frames

2013-04-14 Thread Rui Barradas
Hello, I'm not completely sure I've understood. Your variable 'letters' iholds the names of the data.frames? If so it's better if you put yoyr data.frames in a list and then use that list. Something like lst <- list(A, B) for (i in seq_along(lst)){ lst[[i]][["Rate"]] <- ROC(lst[[i]]