Hi Newbie question:
I have a set of data frames that I want to do the same calculations on each. I've found out that I can put them in a list and loop through the list to do the calculation, but not put the results back into each data.frame.. For example three data frames cats, dogs, birds where >cats name eats_kg 1 bob 3 2 garfield 4 3 chuck 6 and dogs and birds are similar but not same length. On each data frame I now want to add a column with cost of food by calculating "eats_kg"*price of food. So question is, can I put all data frames into one loop which returns a new column for each? Ive tried MyList <- list(cast,dog,birds) for(i in 1:length(MyList)){ price <- as.data.frame(myList[i])[,2] * cost .. and then Im stuck. How can I put "price" back into each data frame? Thanks in advance. ______________________________________________ R-help@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.