我有很多数据框(week1
, ..., week20
),我想循环调用它们:
for (i in 1:20) {
function(weeki)
}
直觉上,我想做这样的事情:
weeki <- paste ("week", i, sep="")
其中weeki
指的是数据框。
我可以列一个清单:
week <- list (week1, week2, ..., week20)
for (i in 1:20) {
function(week[[i]])
}
但这无济于事,因为我必须在该列表中写入数据框的名称。我希望“week”成为所有“weeki”数据框的列表,并且那周[[i]] = weeki