在 R 中标记循环图
我正在使用一个循环来绘制直方图,同时按 column_a
的不同值进行分组,效果非常好。代码如下:
par(ask=F)
for (i in unique(Data$column_a)) {
dat <- Data[Data$column_a== i, ]
plotdist(dat$count,histo = TRUE, demp = TRUE, discrete = T,
pch = 16, col = "dodgerblue1")
}
唯一的问题是我无法相对于 column_a
值标记每个数字以将这些数字与另一个数字区分开来。
预先感谢您的帮助。
我的数据由损失数量组成,列名称为“count”,column_a(R,I,F)) 中有 3 个不同的值。我想绘制这三个值的损失数直方图。
I am using a loop for plotting the histogram, group by different values of column_a
at once which works perfectly fine. Here's the code:
par(ask=F)
for (i in unique(Data$column_a)) {
dat <- Data[Data$column_a== i, ]
plotdist(dat$count,histo = TRUE, demp = TRUE, discrete = T,
pch = 16, col = "dodgerblue1")
}
The only problem is that I cannot label each figure relative to column_a
value to differentiate the figures from on another.
Thanks in advance for the help.
my data consists of number of losses with the column name of "count" with 3 distinct value in column_a(R,I,F)). and I want to plot the histogram of number of losses for these three values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个有点hacky的解决方案是改变函数本身。
下面是 alteret 函数,它不包括
title
参数(并且仅适用于您问题中的配置!)现在要向绘图添加标题,只需使用以下命令:
编辑:添加虚拟数据测试提供的循环。
A somewhat hacky solution would be to alter the function itself.
Below is the alteret function, which uncludes the
title
argument (and only works for the configuration you had in your question!)To now add a title to your plot, simply use this:
Edit: Added dummy data to test the provided loop.