In R, to apply some function to a column, you can do:
df$col <- someFunction(df$col)
Now my question is, how do you the similar task when you have data frames in a nested list? Say I have a following list like this, where I have data frames in the second level from the root.
+------+------+
type1 | id | name |
+----------->|------|------|
| | | |
| | | |
year1 | +------+------+
+------------------+
| |
| | +------+------+-----+
| | type2 | meta1|meta2 | name|
| +----------> |------|------|-----|
| | | | |
+ +------+------+-----+
| type1 +------+------+
| +---------> | id |name |
| | |------|------|
| year2 | | | |
list +----------------->+ | | |
+ | +------+------+
| | type2 +------+------+-----+
| +---------> | meta1|meta2 |name |
| |------|------|-----|
| | | | |
| type1 +------+------+-----+
| +----------> +------+------+
| | | id |name |
| year3 | |------|------|
+-----------------+ | | |
| | | |
| type2 +------+------+
+----------> +------+------+-----+
|meta1 | meta2|name |
|------|------|-----|
| | | |
+------+------+-----+
And I want to modify the "name" column in each of the data frame in the leaves with some functions and store the results there. How do you do that?
Here is the example data:
data<-list()
data$yr2001$type1 <- df_2001_1 <- data.frame(index=1:3,name=c("jack","king","larry"))
data$yr2001$type2 <- df_2001_2 <- data.frame(index=1:5,name=c("man","women","oliver","jack","jill"))
data$yr2002$type1 <- df_2002_1 <- data.frame(index=1:3,name=c("janet","king","larry"))
data$yr2002$type2 <- df_2002_2 <- data.frame(index=1:5,name=c("alboyr","king","larry","rachel","sam"))
data$yr2003$type1 <- df_2003_1 <- data.frame(index=1:3,name=c("dan","jay","zang"))
data$yr2003$type2 <- df_2003_2 <- data.frame(index=1:5,name=c("zang","king","larry","kim","fran"))
say I want to uppercase all of the names in in the name column in each data frame stored in the list