我正在研究 R 中的一个相当大的数据集,该数据集分为几个数据帧。
问题是我用整个集合做一些事情,有时我只需要使用或修改集合的一部分并且我的选择器变得非常笨重,fe
aListOfItems$attribute4([aListOfItems$attribute1 == true & aListOfItems$attribute2 == 6
& aListOfItems$attribute3 == "C"),] <- aListOfItems([aListOfItems$attribute1 == true &
aListOfItems$attribute2 == 6 & aListOfItems$attribute3 == "C"),aListOfItems$attribute5]
* aListOfItems([aListOfItems$attribute1 == true & aListOfItems$attribute2 == 6 &
aListOfItems$attribute3 == "C"),aListOfItems$attribute7]
(这会将所有条目的选定部分的属性 4 设置为 (attribute5 * attribute6) 。)
这很难阅读、理解和编辑。
由于 RAM 的原因,将它们拆分为不同的数据帧并不是一个真正的选择,因为我会定期刷新这些数据并重建所有单独的数据帧也会很痛苦。
那么,有没有办法做类似的事情
items_t6C <- &(aListOfItems([aListOfItems$attribute1 == true & aListOfItems$attribute2
== 6 & aListOfItems$attribute3 == "C"),]
所以我可以使用
items_t6C$attribute4 <- # do something
或者,也许可以将这样的选择器存储在字符串变量中并使用它?