dplyrで非標準的な評価についてhttp://dplyr.tidyverse.org/articles/programming.htmlを読んだが、まだ動作させることができない。r dplyr非標準的な評価 - 関数の順序付け棒プロット
plot_column < - のmutate文が無効になっているとき、 "columnA"
raw_data %>%
group_by(.dots = plot_column) %>%
summarise (percentage = mean(columnB)) %>%
filter(percentage > 0) %>%
arrange(percentage) %>%
# mutate(!!plot_column := factor(!!plot_column, !!plot_column))%>%
ggplot() + aes_string(x=plot_column, y="percentage") +
geom_bar(stat="identity", width = 0.5) +
coord_flip()
が正常に動作します。ただし、高さでバーを並べ替えるために有効にすると、1つのバーだけが返されます。
上記のステートメントを関数/に変換するにはどうすればよいですか?
例データセットは次のようになります。
columnA,columnB
a, 1
a, 0.4
a, 0.3
b, 0.5
編集
サンプル:
mtcars %>%
group_by(mpg) %>%
summarise (mean_col = mean(cyl)) %>%
filter(mean_col > 0) %>%
arrange(mean_col) %>%
mutate(mpg := factor(mpg, mpg))%>%
ggplot() + aes(x=mpg, y=mean_col) +
geom_bar(stat="identity")
coord_flip()
意志出力命じた棒グラフ。 これを列に置き換えて複数の棒がある関数にどのようにラップできますか?
まだ100%存在していないようです。私はまだグループごとに1つのバーではなく、1つのバーの元の結果を取得します。 –
ああ申し訳ありませんが、私にチェックさせてください! – friep
それは変だけど、私はRのきれいなセッションをしたし、私のために働いた。これをパッケージのバージョンとともにコードに追加します。 – friep