通常のplotコマンドでこれを行うには、通常は1つのプロットを作成してからlines()
関数を使用して行を追加します。
そうでない場合は、latticeまたはggplot2を使用できます。ここではいくつかのデータがあります:
df <- data.frame(a = runif(10), b = runif(10), c = runif(10), x = 1:10)
あなたは格子からxyplot()
を使用することができます。ggplot2で
またはgeom_line()
を:
library(ggplot2)
ggplot(melt(df, id.vars="x"), aes(x, value, colour = variable,
group = variable)) + geom_line() + theme_bw()
ここで(this post on the learnr blogから)各ペアでのポイントを含む別の例です:
library(lattice)
dotplot(VADeaths, type = "o", auto.key = list(lines = TRUE,
space = "right"), main = "Death Rates in Virginia - 1940",
xlab = "Rate (per 1000)")
そしてggplot2を使用して同じプロット:
library(ggplot2)
p <- ggplot(melt(VADeaths), aes(value, X1, colour = X2,
group = X2))
p + geom_point() + geom_line() + xlab("Rate (per 1000)") +
ylab("") + opts(title = "Death Rates in Virginia - 1940")
私はエラーを取得しています。エラー:機能を見つけることができなかった「ドットプロットは、」私はこれを使用することがCRANから何かを必要ですか? – hekevintran
今、図書館の呼び出しが表示されます。ご回答有難うございます! – hekevintran