dev_history.Rmd empty

library(testthat)

my_function

Uses "function()" in parameter's documentation

#' Call a stat function
#' 
#' Run a stat function (ex : mean, min, max)
#' function()
#' 
#' @param x A numeric vector
#' @param stat_function A stat function (ex : mean, min, max)
#' 
#' @examples
#' 
#' @export
# function() I can write "function()" in code comments really everywhere!
my_function <- function(x, stat_function){
  stat_function(x, na.rm = TRUE) # function() comment after code
# function() in code comment
}
my_function(x = rnorm(100), stat_function = mean)
test_that("my_function works", {
  expect_true(inherits(my_function, "function")) 
})

Should be saved in a proper .R file

#' Add one to a numeric value
#'  
#' @param x A numeric value
#' 
#' @examples
#' 
#' @export
add_one <- function(x){
  x + 1
}
add_one(x = 1)
test_that("add_one works", {
  expect_equal(object = add_one(1), expected = 2) 
})
# Run but keep eval=FALSE to avoid infinite loop
# Execute in the console directly
fusen::inflate(flat_file = "dev/dev_history.Rmd")


Try the fusen package in your browser

Any scripts or data that you put into this service are public.

fusen documentation built on Aug. 17, 2023, 5:09 p.m.