2

ggplot2 でプロットを作成しようとしています。problem_accept_df という名前のデータは次のとおりです。

Order Application probscore
1  Integrated 0.8333333
1      Tabbed 0.7777778
2  Integrated 0.8965517
2      Tabbed 0.7777778
3  Integrated 0.7931034
3      Tabbed 0.7777778
4  Integrated       0.7
4      Tabbed 0.6538462
5  Integrated 0.9285714
5      Tabbed 0.8333333
6  Integrated 0.9310345
6      Tabbed 0.8148148
7  Integrated 0.8571429
7      Tabbed 0.8518519
8  Integrated 0.9333333
8      Tabbed 0.6923077
9  Integrated 0.9310345
9      Tabbed 0.8461538
10  Integrated 0.9285714
10      Tabbed       0.8

プロットを作成するコードは次のとおりです。

ggplot(problem_accept_df, aes(x=Order, y=probscore, color=Application,
group=Application)) + 
xlab('Order') +
ylab('Problem scores') +
geom_line(position=pd, size=2) +
geom_point(position=pd, size=4) +
labs(title='Acceptable proportion of problem scores')

プロットが作成されますが、値が等間隔でなくても、等間隔の目盛りに y 値が表示されます。プロットには、範囲ではなく、個々の y 値も表示されます。それを変更しようとしましたが ( scale_y_continuous(breaks=seq(0.5, 1, 0.1)))、エラー メッセージが表示Error: Discrete value supplied to continuous scaleされるので、問題はより基本的なものに違いありません。何をすべきかについての提案をいただければ幸いです。

4

1 に答える 1

0

これは通常、データ(あなたの場合probscore)が因子であり、連続変数ではない場合に発生します。

> d <- data.frame(x=c(0,1), y=factor(c(0.5, 1.5)))
> d
  x   y
1 0 0.5
2 1 1.5
> levels(d$x)
NULL
> levels(d$y)
[1] "0.5" "1.5"
> library(ggplot2)
> ggplot(d, aes(x=x, y=y)) + geom_point() + scale_y_continuous()
Error: Discrete value supplied to continuous scale
> ggplot(d, aes(x=x, y=as.numeric(as.character(y)))) + geom_point() + scale_y_continuous()
于 2012-12-11T19:41:38.423 に答える