1
私はしばしば自分自身がこのやって見つける:ggplot:データフレーム内の値のプロット頻度カウント(前処理なしで)
# Original data
df.test <- data.frame(value=floor(rexp(10000, 1/2)))
# Compute the frequency of every value
# or the probability
freqs <- tabulate(df.test$value)
probs <- freqs/sum(freqs)
# Create a new dataframe with the frequencies (or probabilities)
df.freqs <- data.frame(n=1:length(freqs), freq=freqs, probs=probs)
# Plot them, usually in log-log
g <- ggplot(df.freqs, aes(x=n, y = freq)) + geom_point() +
scale_y_log10() + scale_x_log10()
plot(g)
はそれがちょうど中間データセットを作成することなく、ggplot
を使用して行うことができますか?頻度数については
をグレート、ありがとう!正規化された頻度(確率)はどうですか? – alberto
'stat_summary'を使った方が良い解決法があるかもしれませんが、私は手前でデータを準備するほうがずっと簡単です。次のようなものがあります: 'ggplot(data.frame(prop.table(table(df.test)))、aes(x = df.test、y = Freq))+ geom_point()'。 – Psidom