我玩过但从未完全开发过的东西是一组函数,使这些结构在降价中更易于管理。在这种情况下,toggle_text
toggle_text <- function(condition, true, false)
{
coll <- checkmate::makeAssertCollection()
checkmate::assert_logical(x = condition,
len = 1,
add = coll)
checkmate::assert_character(x = true,
len = 1,
add = coll)
checkmate::assert_character(x = false,
len = 1,
add = coll)
checkmate::reportAssertions(coll)
if (condition) true
else false
}
哪个可以用作
---
title: "Untitled"
output: html_document
---
```{r}
install.packages("checkmate") #comment out if installed
library(checkmate)
toggle_text <- function(condition, true, false)
{
coll <- checkmate::makeAssertCollection()
checkmate::assert_logical(x = condition,
len = 1,
add = coll)
checkmate::assert_character(x = true,
len = 1,
add = coll)
checkmate::assert_character(x = false,
len = 1,
add = coll)
checkmate::reportAssertions(coll)
if (condition) true
else false
}
this_p_value = 0.03
```
This is `r toggle_text(this_p_value <= 0.05, "", "not")` significant as p = `r this_p_value`.
```{r}
this_p_value = 0.07
```
This is `r toggle_text(this_p_value <= 0.05, "", "not")` significant as p = `r this_p_value`.