---
title: "dev_history.Rmd empty"
output: html_document
editor_options: 
  chunk_output_type: console
---

```{r development, include=FALSE}
library(testthat)
```

## Common title for 2 functions

```{r function}
#' My median
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_median(2:20)
my_median <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples}
my_median(1:12)
```

```{r tests}
test_that("my_median works properly and show error if needed", {
  expect_error(my_median("text"))
})
```

```{r function-2}
#' My median2
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_median2(2:20)
my_median2 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples-2}
my_median2(1:12)
```

```{r tests-2}
test_that("my_median2 works properly and show error if needed", {
  expect_error(my_median2("text"))
})
```

# Two functions, same chunk param
## fun_chunk1

```{r function-fun_chunk1, filename = "fun_chunk1"}
#' My fun_chunk1
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_fun_chunk1(2:20)
my_fun_chunk1 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples-fun_chunk1}
my_fun_chunk1(1:12)
```

```{r tests-fun_chunk1}
test_that("my_fun_chunk1 works properly and show error if needed", {
  expect_error(my_fun_chunk1("text"))
})
```

## fun_chunk2

```{r function-fun_chunk2, filename = "fun_chunk1"}
#' My fun_chunk2
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_fun_chunk2(2:20)
my_fun_chunk2 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples-fun_chunk2}
my_fun_chunk2(1:12)
```

```{r tests-fun_chunk2}
test_that("my_fun_chunk2 works properly and show error if needed", {
  expect_error(my_fun_chunk2("text"))
})
```

# Two functions, same `@rdname`
## fun_rdname1

```{r function-fun_rdname1}
#' My fun_rdname1
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @rdname same_rdname
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_fun_rdname1(2:20)
my_fun_rdname1 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples-fun_rdname1}
my_fun_rdname1(1:12)
```

```{r tests-fun_rdname1}
test_that("my_fun_rdname1 works properly and show error if needed", {
  expect_error(my_fun_rdname1("text"))
})
```

## fun_rdname2

```{r function-fun_rdname2}
#' @rdname same_rdname
#' @importFrom stats median
#' @export
my_fun_rdname2 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  median(x, na.rm = na.rm)
}
```

```{r examples-fun_rdname2}
my_fun_rdname2(1:12)
```

```{r tests-fun_rdname2}
test_that("my_fun_rdname2 works properly and show error if needed", {
  expect_error(my_fun_rdname2("text"))
})
```

# Two functions, mix same `@filename` + chunk param
## fun_filename1

```{r function-fun_filename1}
#' My fun_filename1
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @filename same_filename
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_fun_filename1(2:20)
my_fun_filename1 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples-fun_filename1}
my_fun_filename1(1:12)
```

```{r tests-fun_filename1}
test_that("my_fun_filename1 works properly and show error if needed", {
  expect_error(my_fun_filename1("text"))
})
```

## fun_filename2

```{r function-fun_filename2, filename = "same_filename.R"}
#' My fun_filename2
#'
#' @param x Vector of Numeric values
#' @inheritParams stats::median
#'
#' @return
#' Median of vector x
#' @export
#'
#' @examples
#' my_fun_filename2(2:20)
my_fun_filename2 <- function(x, na.rm = TRUE) {
  if (!is.numeric(x)) {stop("x should be numeric")}
  stats::median(x, na.rm = na.rm)
}
```

```{r examples-fun_filename2}
my_fun_filename2(1:12)
```

```{r tests-fun_filename2}
test_that("my_fun_filename2 works properly and show error if needed", {
  expect_error(my_fun_filename2("text"))
})
```

```{r development-1, eval=FALSE}
# Run but keep eval=FALSE to avoid infinite loop
# Execute in the console directly
fusen::inflate(flat_file = "dev/dev_history.Rmd")
```
