縱向數據集我有數據集:創建具有重塑
top100_repository_name month monthly_increase monthly_begin_at monthly_end_with
Bukkit 2012-03 9 431 440
Bukkit 2012-04 19 438 457
Bukkit 2012-05 19 455 474
CodeIgniter 2012-03 15 492 507
CodeIgniter 2012-04 50 506 556
CodeIgniter 2012-05 19 555 574
我用下列R-代碼:
library(reshape)
latent.growth.data <- read.csv(file = "LGC_data.csv", header = TRUE)
melt(latent.growth.data, id = c("top100_repository_name", "month"), measured = c("monthly_end_with"))
cast(latent.growth.data, top100_repository_name + month ~ monthly_end_with)
,我想用來創建一個具有以下結構的數據集:
top100_repository_name 2012-03 2012-04 2012-05
Bukkit 440 457 474
CodeIgniter 507 556 574
但是,當我運行我的代碼時,我得到以下輸出:
Using monthly_end_with as value column. Use the value argument to cast to override this choice
Error in `[.data.frame`(data, , variables, drop = FALSE) :
undefined columns selected
如何修改我的代碼以便生成所需的輸出?
我敢肯定,我的編輯是正確的,但請覈實。 –
你需要做一些事情:(i)將熔化物的結果保存到一個物體,例如'latent.growth.melt',然後按照下面的'latent.growth.melt'運行。如果使用更新的reshape2包(推薦),則使用dcast()而不是cast() - 最後一行應該是'dcast(latent.growth.melt,top100_repository_name〜month,value.var =「value 「)'。你可以看看爲什麼通過看'latent.growth.melt'。 – Dennis