everdark / ggplot2_lecture_dsc2014

Place to store my slides for DSConf 2014 in Taipei
0 stars 4 forks source link

P36 無法正確執行 #18

Open ntuaha opened 10 years ago

ntuaha commented 10 years ago
siris_ag <- siris_ag[,list(Count=.N), by='Species,Fat'][ ,Pct:=Count/sum(Count), by='Species']

Error in [.data.frame(siris_ag, , list(Count = .N), by = "Species,Fat") : unused argument (by = "Species,Fat")

library(sqldf);

沒有這個library

mansunkuo commented 10 years ago

options(gsubfn.engine='R'); library(sqldf) Loading required package: gsubfn Loading required package: proto Loading required package: RSQLite Loading required package: DBI Loading required package: RSQLite.extfuns tmp1 <- sqldf('select Species, Fat, count(_) as Count from siris group by Species, Fat') tmp2 <- sqldf('select Species, sum(Count) as cnt_by_species from tt group by Species') Error in sqliteExecStatement(con, statement, bind.data) : RS-DBI driver: (error in statement: no such table: tt) sqldf('select tmp1.Species, Fat, Count, (Count_1.0 / cnt_by_species) as Pct

  • from tmp1 join tmp2 on tmp1.Species = tmp2.Species') -> siris_ag Error in sqliteExecStatement(con, statement, bind.data) : RS-DBI driver: (error in statement: no such table: tmp2)
everdark commented 10 years ago

tmp2 <- sqldf('select Species, sum(Count) as cnt_by_species from tt group by Species') 這邊有typo,tt應該是tmp1,會修正。

Error in [.data.frame(siris_ag, , list(Count = .N), by = "Species,Fat") : 
unused argument (by = "Species,Fat")

這個錯誤我無法重製。

然後這兩頁基本上是eval=FALSE因為只是想展示其他library可能的作法,不想因此就讓Tutorial套件得多了好幾個dependencies,所以使用者如果嘗試要跑可能會遇到沒裝library的問題。理論上走到這一步他們應該有能力自己裝套件了。

wush978 commented 10 years ago

可以將套件放到DSC2014Tutorial之中的Suggests之中