Hello everyone I'm a new R user and have some questions about lists indexing, names and the lapply function.
first have a look to my data (names changed) it's a rainfall record for 67 stations, str(data) List of 67 $ e9999.somename.xx.txt :'data.frame': 456 obs. of 5 variables: ..$ Y : int [1:456] 1960 1960 1960 1960 1960 1960 1960 1960 1960 1960 ... ..$ M : int [1:456] 1 2 3 4 5 6 7 8 9 10 ... ..$ PRE : num [1:456] 0 0 0 0 10.6 ... ..$ COD : Factor w/ 2 levels "FE","O": 2 2 2 2 2 2 2 2 2 2 ... ..$ piece: num [1:456] -0.874 -0.874 -0.874 -0.874 -0.66 ... ... on a single a data frame it is possible to use names or <- to change column name "piece" for something more meaningful to me like "my_calc" i don't know how generalize that to a list of dataframes perhaps something like lapply(data, names,...) "piece" is in fact the result of few lines of ugly code with rapply, sapply and llply the names were lost somewhere... 1. How do i change "piece" name? I need to subset every dataframe in the list by "$M" and then over this subset aggregate using mean of "$piece" on a single data frame i do z <- subset(e999.somedata.xx.txt, M==c(1,2,3)) z <- aggregate(z[,5], list(z[,1]),mean) I tried this but it doesn't behave the way i expected, (because it creates a single data frame and a want a list of data frames). for (i in data){ z <- subset(i, i$M==c(1,2,3)) z <- aggregate(z[,5], list(z[,1]),mean) } 2. how to subset and aggregate?, perhaps lapply again? a rainfall of thanks to the charitable soul who can help with this basics questions, i just don get indexation or naming conventions! -- View this message in context: http://r.789695.n4.nabble.com/renaming-a-list-of-data-frames-y-calculating-with-lapply-tp3044908p3044908.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.