3
多くのことを試しましたが、グリッドを作成するためのプロットを取得できません。私が欲しいのは積み重ねた塗りつぶしの図表ですが、私は理解できないエラーが続いています。私のデータに年(サイクル)しかない場合、これは機能します。棒グラフをグリッドに正しく取り込むことができない
p2000 <- ggplot(c2000,aes(x=c2000$RealCode, y=c2000$Amount, fill=c2000$Party, colors=c2000$Party)) +
geom_bar(position="fill",colour="black") + cbgFillPalette + xlab("") + ylab("") + opts(title="2000")+
opts(legend.position = "none")+geom_hline(yintercept = .5, colour = "black")+
facet_grid(. ~ Cycle)
p2000
私は1年以上経っても、yエラーは見つかりません。
c2000[1:5,]
RealCode Cycle Party Amount
1 A 2000 D 5581676
2 B 2000 D 2547396
3 C 2000 D 6867211
4 D 2000 D 2839314
5 E 2000 D 6255726
> p2000 <- ggplot(c2000,aes(x=c2000$RealCode, y=c2000$Amount, fill=c2000$Party, colors=c2000$Party)) +
+ geom_bar(position="fill",colour="black") + cbgFillPalette + xlab("") + ylab("") + opts(title="2000")+
+ opts(legend.position = "none")+geom_hline(yintercept = .5, colour = "black")+
+ facet_grid(. ~ Cycle)
> p2000
Error in pmin(y, 0) : object 'y' not found
> p2000 <- ggplot(c2000,aes(x=c2000$RealCode, y=c2000$Amount, fill=c2000$Party, colors=c2000$Party)) +
+ geom_bar(position="fill",colour="black") + cbgFillPalette + xlab("") + ylab("") + opts(title="2000")+
+ opts(legend.position = "none")+geom_hline(yintercept = .5, colour = "black")+
+ facet_grid(. ~ c2000$Cycle)
> p2000
Error in layout_base(data, cols, drop = drop) :
At least one layer must contain all variables used for facetting
これは、1つのプロットは次のようになります。私のコメントが正解であるように思われたので、私は答えとして、それを追加します
私は再現可能な例がなければ助けにはなりませんが、少なくとも 'x = c2000 $ RealCode'のような美学をマッピングするべきではありません。あなたは単に 'x = RealCode'を実行するべきです。 – joran
すべてを変更して列名にするだけで問題は解決しました。ありがとう! – brian