我想使用子集功能动态创建一些数据帧。目前:
bucket = c("branch", "rich")
sector_filter = c("test==1","test==2")
for (i in 1:length(bucket))
{
eval(parse(text = paste0(bucket[i], "=subset(data, ", sector_filter[i],")")))
}
有没有办法正确地做到这一点,这可行,但不是很优雅。与合并相同的问题。我怎么能避免这个
for (i in 1:length(bucket))
{
bucket[i] = merge(bucket[i], var, by = "qtr", all.x = T)
}