我有很长的脚本用来创建一些流程。
xm <- 1
produccion_tx <- data.frame(produccion_mes_mes[xm]) # Creates the table in a df
source("4_WMIN.R") # makes the maths
source("5_WMIN.R") # export an excel file
source("6_WMIN.R") # saves the data
mes_t1 <- mylist
xm <- 2
produccion_tx <- data.frame(produccion_mes_mes[xm]) # Creates the table in a df
source("4_WMIN.R") # makes the maths
source("5_WMIN.R") # export an excel file
source("6_WMIN.R") # saves the data
mes_t2 <- mylist
....and等等。
我希望将所有这些数据存储在名为: mes_t1、mes_t2等的对象中。
for (xm in 1:37) {
produccion_tx <- data.frame(produccion_mes_mes[xm]) # Creates the table in a df
source("4_WMIN.R")# makes the maths
source("5_WMIN.R")#export an excel file
source("6_WMIN.R")# saves the data
mes_t%s <- mylist #the results are in mylist
}
如何使用mes_t1、mes_t2、mes_t3等名称保存每个循环中的表……等?
发布于 2017-07-12 03:12:45
试试assign
for (xm in 1:37) {
i = 1
# do some stuff
assign(paste0('mes_t', i), mylist)
i = i + 1
}
https://stackoverflow.com/questions/45042592
复制相似问题