我设法使用RStudio和roxygen2创建了一个包.整个包创建过程没有任何错误和警告.无论如何,我的问题是如何创建我的包及其功能的PDF文档?提前致谢.
任何人都可以帮助我解释为什么 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) 我想知道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)