如何計算data_foobar
的每個單元的相對頻率,相對於data_baseline
(= 100%)?兩者都包含的物品絕對計數,按年,而是data_foobar
僅包含年值> 0如何計算data.frame中每個單元格相對於第二個data.frame的相對頻率?
樣本數據(更新):
data_baseline <- structure(list(Year = 2010:2014, `Area Studies` = c(3636L, 4247L,
3922L, 2050L, 201L), Arts = c(2082L, 1993L, 1859L, 974L, 87L)), .Names = c("Year",
"Area Studies", "Arts"), row.names = 111:115, class = "data.frame")
data_foobar <- structure(list(Year = 2011:2014, `Area Studies` = c(1L, 2L, 2L,
NA), Arts = c(5L, 8L, 3L, NA)), .Names = c("Year", "Area Studies",
"Arts"), row.names = c("58", "59", "60", "61"), class = "data.frame")
如何將它與plyr/dplyr做些什麼呢?
您在此處撰寫的大部分內容對於該問題不是必需的。我認爲你可以安全地刪除一切之前「我怎麼......」 – Frank