2016-01-23 6 views
40

多くの私のプログラムでは、ggplot2を使ってグラフをレンダリングしてきました。私はshinyapps.ioにそれらをロードして、彼らは絶対にうまく動作しています。私は私のマシン上でプログラムを実行しようとすると、しかし、私は次のエラーを取得しています:エラー:ggplot2のstat_count()

Error : stat_count() must not be used with a y aesthetic. 

次のコード例である:

ggplot(hashtg, aes(x=reorder(hashtag, Freq), y = Freq, fill = hashtag)) + geom_bar(stat="identity") + 
       geom_bar(width = 0.4) + xlab("Hashtags Used") + ylab("Number of responses") + 
       geom_text(aes(label=Freq), hjust = 1, colour = "white") 

実際のコードは、バーグラフの数の引数を持っていますタイトルなどのテーマ&注釈がありますが、出力を妨げることはありません。私はコード内のFreqが特定の用語の頻度である集約データを使用しています。私が助けを求めたとき、バープロットにstat = "identity"を使うよう指示を繰り返しました。

ご協力いただければ幸いです。

次のようにセッション情報は、次のとおりです。

R version 3.2.0 (2015-04-16) 
Platform: x86_64-apple-darwin13.4.0 (64-bit) 
Running under: OS X 10.10.3 (Yosemite) 

locale: 
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] wordcloud_2.5  RColorBrewer_1.1-2 SnowballC_0.5.1  ggplot2_2.0.0  plyr_1.8.3   
[6] chron_2.3-47   RCurl_1.95-4.7  bitops_1.0-6   ROAuth_0.9.6   RJSONIO_1.3-0  
[11] twitteR_1.1.9  base64enc_0.1-3  tm_0.6-2    NLP_0.1-8   stringr_1.0.0  
[16] shinydashboard_0.5.1 shinyIncubator_0.2.2 shiny_0.12.2   

loaded via a namespace (and not attached): 
[1] Rcpp_0.12.1  tools_3.2.0  digest_0.6.8  bit_1.1-12  jsonlite_0.9.17 gtable_0.1.2  
[7] DBI_0.3.1   rstudioapi_0.3.1 curl_0.9.3  parallel_3.2.0 httr_1.0.0  bit64_0.9-5  
[13] grid_3.2.0  R6_2.1.1   magrittr_1.5  scales_0.3.0  htmltools_0.2.6 colorspace_1.2-6 
[19] mime_0.4   xtable_1.7-4  httpuv_1.3.3  labeling_0.3  stringi_0.5-5  munsell_0.4.2  
[25] slam_0.1-32  rjson_0.2.15  rstudio_0.98.1103 

繰り返しに、同じコードがshinyapps.ioで問題なく動作します。

+1

あなたはあなたのsessionInfo()をサーバーと比較していますか? – MLavoie

+0

まだ、それを行う方法がわかりません。私は最近Javaを更新し、JREとAndroid Studioをインストールしました...それは矛盾しますか? – LeArNr

+3

ggplot2のバージョン2.0.0へのアップデートでは、いくつかの大きな変更がありました。バージョンを比較し、アップデートからNEWSを調べます。 – Roland

答えて

80

このエラーは、このリンク(http://tutorials.iq.harvard.edu/R/Rgraphics/Rgraphics.html) で解決しました。

geom_bar()で要約しようとしている列は既に要約されています。 stat=stat_count(デフォルトはgeom_bar())を識別情報に変更する必要があります。

+ geom_bar(stat="identity") 

または、代わりにgeom_colを使用できます。

+0

メッセージをありがとう....実際問題は定義中ですgeom_bar(stat = 'identity "、width = 0.4)のように、stat =" identity "を指定すると解決されるwidth引数は、geom_barに関連するすべての引数を一緒に宣言する必要があります。以前のバージョンからggplot2の新しいバージョンに変更されました。 – LeArNr