我在列表salesList
中有以下类型的一组数据框:
X. Game Owners.before Owners.after Sales Increase Price Max.discount Userscore..Metascore.
1 14 Call of Duty: Advanced Warfare - Multiplayer 1,617,539 ±75,027 6,467,189 ±63,403 4,849,650 299.82% $59.99 25% ($44.99) N/A (78%)
2 63 Grand Theft Auto V 0 ±0 2,077,609 ±36,281 2,077,609 0% $59.99 0% ($59.99) 83% (96%)
3 59 Dungeon of the Endless 194,543 ±26,101 2,173,362 ±37,100 1,978,819 1017.16% $11.99 50% ($6.49) 90% (79%)
4 157 DiRT 3 Complete Edition 298,664 ±32,332 976,615 ±24,933 677,951 226.99% $29.99 20% ($23.99) 89% (86%)
5 1 Counter-Strike: Global Offensive 12,256,215 ±201,631 12,671,726 ±87,533 415,511 3.39% $14.99 0% ($14.99) 93% (83%)
6 473 Killing Floor 2 0 ±0 279,056 ±13,348 279,056 0% $29.99 0% ($29.99) 83% (N/A)
我想使用ddply将以下指令(针对单个数据框写入)应用于列表中的所有数据帧:
owners.after <- strsplit(sales$Owners.after, split=" ±")
sales$owners.after.est <- sapply(owners.after, function(i) i[1])
sales$owners.after.band <- sapply(owners.after, function(i) i[2])
owners.before <- strsplit(sales$Owners.before, split=" ±")
sales$owners.before.est <- sapply(owners.before, function(i) i[1])
sales$owners.before.band <- sapply(owners.before, function(i) i[2])
问题在于访问列表中名为Owners.after
和Owners.before
的每个列并拆分数据。