I have many data in the global environment. And I want to loop some of them (have a pattern in their names) for calculation. For example, how to (1)select DataX1, DataX2, DataX3 for a loop, and (2)add 1 on them, then (3)storage the result in a new df with name pattern like r.DataX1
DataX1 <- sample(1:10)
DataX2 <- sample(1:10)
DataX3 <- sample(1:10)
DataY1 <- sample(1:10)
DataY2 <- sample(1:10)
DataY3 <- sample(1:10)
list = apropos("DataX.")
for (i in 1:3){
X <- list[[i]]
r.DataXi <- X + 1
}
BTW, how to select all the dataframe in the current global environment with a "Y" in the middle, with a "3" at the end, with a "D" at the beginning and loop them?
Thank you.