作者celestialgod (攸蓝)
看板R_Language
标题Re: [问题] 想连续处理多个column by factor
时间Thu Oct 24 18:34:44 2013
最简单的方式就是用list去处理,范例code如下:
Product = "Product1" #可自行输入产品编号
Month = "July" #可指定月份
data.l = lapply(1:10, function(k){
eval(parse(text=paste("read.csv(\"D:/year", k, ".csv\")", sep="")))
}
)
output.l = lapply(data.l, function(ll){
eval(parse(text=paste("subset(ll, ", "Month==\"", Month, "\", select = ",
Product, ")", sep="")))
}
)
output.fr = Reduce(data.frame, output.l)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.152.220
※ 编辑: celestialgod 来自: 140.116.152.220 (10/24 18:51)
1F:推 peiwinds:THX A LOT 10/28 17:03