小编Nus*_*sig的帖子

使用RStudio创建包文档?

我设法使用RStudio和roxygen2创建了一个包.整个包创建过程没有任何错误和警告.无论如何,我的问题是如何创建我的包及其功能的PDF文档?提前致谢.

r package

7
推荐指数
1
解决办法
798
查看次数

函数expect_that从testthat遇到错误

任何人都可以帮助我解释为什么 expect_that 如果[]添加到停止消息不起作用,即f1工作但f2不工作.

library(testthat)
f1 <- function(x){
  if(  x >= 1 ){
    stop("error 1")
  }
}
expect_that(f1(x=1.4), throws_error("error 1"))
f2 <- function(x){
  if(  x >= 1 ){
    stop("error [1]")
  }
}
expect_that(f2(x=1.4), throws_error("error [1]"))
Run Code Online (Sandbox Code Playgroud)

r testthat

4
推荐指数
1
解决办法
200
查看次数

geom_histogram:第一个bin的默认原点是什么?

我想知道ggplot2为给定的bin宽度创建的直方图中第一个bin的默认原点.不幸的是,我没有找到在帮助页面的任何信息geom_histogram,geom_bar以及stat_bin.请在下面找到最小的直方图示例ggplot2.

 library(ggplot2)
 x <- rnorm(25)
 binwidth <- (range(x)[2]-range(x)[1])/10
 ggplot(data.frame(x=x), aes(x = x)) +
   geom_histogram(aes(y = ..density..), binwidth = binwidth)
Run Code Online (Sandbox Code Playgroud)

r histogram ggplot2

4
推荐指数
1
解决办法
882
查看次数

标签 统计

r ×3

ggplot2 ×1

histogram ×1

package ×1

testthat ×1