[英]Creating a Histogram with Plot Data (ggplot2)
I am a student programmer attempting to plot a histogram. 我是一名学生程序员,试图绘制直方图。
I have following sample histogram data. 我有以下样本直方图数据。
V1 V2
214 6
215 6
216 6
217 5
218 5
219 6
220 5
221 6
222 6
223 6
224 6
225 6
226 6
227 7
228 7
229 7
230 7
231 8
232 8
233 8
234 8
235 8
The first column being what number is repeated and the second is the amount of repeats. 第一列是重复的次数,第二列是重复的次数。
Currently, I am trying ggplot(df, aes(V1, V2)) + geom_bar()
and I am not producing a graph. 目前,我正在尝试ggplot(df, aes(V1, V2)) + geom_bar()
,但没有生成图形。
I am probably overlooking an option. 我可能忽略了一个选择。 How would you plot this histogram? 您将如何绘制此直方图?
Thank you 谢谢
Just pass the name of your variable into this code. 只需将变量名传递到此代码中即可。
hist(VARIABLE_NAME,
main="Histogram of XYZ",
xlab="X access",
border="blue",
col="green",
xlim=c(100,700),
las=1,
breaks=5)
You can use the repeat function in order to get all of the data fleshed out 您可以使用重复功能来充实所有数据
Data <- rep(V1, each = V2)
hist(Data)
This should do what you want it to and its simple and should be fast 这应该做您想要的事情,它简单并且应该很快
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.