Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
たとえば、通常の積み上げ棒グラフがあります。
ggplot(diamonds, aes(x=color, fill=cut))+geom_bar(position="fill")
そして、同じプロットを作成したいのですが、「カット」タイプの1つだけを残します。例えば「理想」(紫色のもの)。したがって、同じ色を持つ他のすべてのダイヤモンドの中で理想的なダイヤモンドの割合のヒストグラムのようなものになるはずです. ggplot内でこれを行うことはできますか?
データを事前に要約すると、次のように簡単になります。
library("plyr") idl <- ddply(diamonds, .(color), summarize, idealpct = sum(cut=="Ideal")/length(cut)) ggplot(idl, aes(x=color, y=idealpct)) + geom_bar()