SO で以前に尋ねられた質問をして申し訳ありませんが 、ggplot2 でいくつかの単純なデータをプロットしようとしていて、x 軸に沿ってデータをビニングするのに問題があります。私のデータは古い本の視覚的要素 (図、彫刻など) で構成されており、各年の視覚的要素の各タイプの頻度をプロットできます。
#this works
df <- read.table("cleaned_estc_visuals.txt",
header = F,
sep = "\t")
ggplot(data=df, aes(x=V1, y=V3)) +
geom_bar(aes(fill=V2),stat="identity") +
labs(title = "Visuals in Early Modern Books",fill="") +
xlab("Year") +
ylab("Titles")
これにより、次の結果が得られます。
データをより読みやすくするために、x 軸に沿って値を 10 年ごとにビンに入れたいのですが、呼び出しが正しく行われていないようです。
#this doesn't
ggplot(data=df, aes(x=V1, y=V3)) +
geom_bar(aes(fill=V2),binwidth=10,stat="bin")
後者のコードを実行すると、次のようになります。
Mapping a variable to y and also using stat="bin".
With stat="bin", it will attempt to set the y value to the count of cases in each group.
This can result in unexpected behavior and will not be allowed in a future version of ggplot2.
If you want y to represent counts of cases, use stat="bin" and don't map a variable to y.
If you want y to represent values in the data, use stat="identity".
See ?geom_bar for examples. (Deprecated; last used in version 0.9.2)
Error in pmin(y, 0) : object 'y' not found
x軸に沿って10年ごとにビン化する方法を知っている人はいますか? 他の人が提供できるアドバイスに感謝します。