| notify_synthetic | R Documentation |
This function prints a notification message when some or all of
the data used in a project are synthetic (see closed_data and
synthetic). See details for important information.
notify_synthetic(..., msg = NULL, worcs_directory = ".")
... |
Objects of class |
msg |
Expression containing the message to print in case not all
|
worcs_directory |
Character, indicating the WORCS project directory to
which to save data. The default value |
The preferred way to use this function is to provide specific data
objects in the function call, using the ... argument.
If no such objects are provided, notify_synthetic will scan the
parent environment for objects of class worcs_data.
This function is emphatically designed to be included in an 'R Markdown' file, to dynamically generate a notification message when a third party 'Knits' such a document without having access to all original data.
No return value. This function is called for its side effect of printing a notification message.
closed_data synthetic add_synthetic
if(requireNamespace("withr", quietly = TRUE)){
withr::with_tempdir({
file.create(".worcs")
df <- iris
class(df) <- c("worcs_data", class(df))
attr(df, "type") <- "synthetic"
result <- capture.output(notify_synthetic(df, msg = "it is synthetic"))
if(!grepl("synthetic", result)) stop()
df <- df[1:10, ]
closed_data(df, codebook = NULL)
file.remove("df.csv")
result <- capture.output(notify_synthetic(msg = "synthetic"))
if(!grepl("synthetic", result)) stop()
if(requireNamespace("rmarkdown", quietly = TRUE)){
add_manuscript(manuscript = "github_document")
print(readLines("manuscript/manuscript.Rmd"))
rmarkdown::render("manuscript/manuscript.Rmd")
if(!any(grepl("reproduced using synthetic",
readLines("manuscript/manuscript.html")))) stop()
}
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.