- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个使用 qplot()
的函数绘制直方图,例如,
> library(ggplot2)
> d=rnorm(100)
> myfun=function(x) qplot(x)
> myfun(d)
stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> myfun=function(x) print(qplot(x, binwidth=diff(range(x))/30))
> myfun(d)
Error in diff(range(x)) : object 'x' not found
最佳答案
我无法解释为什么会这样(Hadley 可能会通过并这样做)但使用 ggplot
而不是 qplot
解决问题:
d <- data.frame(v1 = rnorm(100))
myfun <- function(x){
p <- ggplot(data = x, aes(x = v1)) +
geom_histogram(binwidth = diff(range(x$v1))/30)
print(p)
}
ggplot
并删除
binwidth = ...
geom_histogram
中的部分使警告再次出现,但随后
suppressMessages
也按预期工作。
qplot
和
ggplot
正在评估参数。但同样,这只是一个猜测......
关于r - 如何在函数内抑制 qplot 的 binwidth 警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7458796/
尝试了解为 geom_histogram 中的每个因子水平分配唯一的 binwidth。到目前为止虽然失败了。 这是可重现的数据 a % group_by(group)%>% mutate(b
这听起来像是一个重复的问题,但希望不是。在基本的R图形直方图函数中,我们有一个选项breaks =“FD”,它为直方图提供了合理大小的binsize,我们是否有任何类似的简单选项ggplot2?或者更
我有一些数据要在多面水平图(等高线)中显示,并且非常惊讶地在其中一个数据基本恒定的面板中看到奇怪的嘈杂等高线。我将整个图层(所有面板)的 binwidth 设置为 1,并且此面板的数据子集在 1 +/
我用 facet_grid 做了一系列直方图并且我希望网格中的每个直方图都具有相同数量的类,在下面的示例中,例如6个类。下面这个例子中的问题是 binwidth = diff(range(x$data
我在没有使用 binwidth 属性的情况下使用 ggplot 绘制了一个简单的直方图。但是,我想查看直方图的 binwidth 值。 set.seed(1234) df `stat_bin()`
我有以下数据 dati <- read.table(text=" class num 1 0.0 63530 2 2.5 27061
我想使用条形图以类似分面的方式比较数据,但缺少数据会导致条形“宽度”不同: 我怎么能 确保相同的条形尺寸(“宽度”)和 [很高兴] 将每个面的面板尺寸缩小到真正需要的尺寸? PS:我不想将空数据显示为
我想使用条形图以类似分面的方式比较数据,但缺少数据会导致条形“宽度”不同: 我怎么能 确保相同的条形尺寸(“宽度”)和 [很高兴] 将每个面的面板尺寸缩小到真正需要的尺寸? PS:我不想将空数据显示为
我已经发现了很多问题,但不知何故它并没有真正帮助我。我不明白如何更改 ggplot2 中密度直方图中的 binwidth,以便概率总和为 1。似乎只有当 binwidth 恰好为 1 时它才有效。这是
感谢您对如何使我的代码或 binwidth 表现出任何想法。我的数据集包含每隔几个小时“4”和每天“24”收集的带时间戳的数据点。我试图在左侧绘制 4 小时堆叠直方图,在右侧绘制 24 小时堆叠直方图
我正在编写一个使用 qplot() 的函数绘制直方图,例如, > library(ggplot2) > d=rnorm(100) > myfun=function(x) qplot(x) 运行它会发出
我遇到了以下场景...... 以下代码生成 2 个相同的直方图: library(ggplot2) data("diamonds") ggplot(diamonds, aes(x=price))
我想用 ggplot2 做一个非常简单的直方图。我有以下 MWE: library(ggplot2) mydf <- data.frame( Gene=c("APC
我有类似的东西[12.414261306701654、10.52589457006108、12.398125569114093、11.900971715356471、11.56627376118999
这是我想要构建的示例 ggplot。在我的数据中,我有一个问题,即我在直方图的小范围内有很多值。因此,我想让 x 轴不成比例地拉伸(stretch)(此处介于 80,81,82,83,84,85 的值
我是一名优秀的程序员,十分优秀!