| scratch_capture | R Documentation |
Saves data to a file in various formats based on the object type and specified format. If no name is provided, uses the name of the object passed in. If no location is provided, uses the scratch directory from the configuration.
scratch_capture(x, name = NULL, to = NULL, location = NULL, n = Inf)
x |
The object to save |
name |
Optional character string specifying the name of the file (without extension). If not provided, will use the name of the object passed in. |
to |
Optional character string indicating the output format. One of: "text", "rds", "csv", "tsv". If not provided, will choose based on object type. |
location |
Optional character string specifying the directory where the file should be saved. If NULL, uses the scratch directory from the configuration. |
n |
Optional number of rows to capture for data frames (default: all rows) |
The input object x invisibly.
if (FALSE) {
# Save a character vector as text
scratch_capture(c("hello", "world"))
# Save a data frame as TSV
scratch_capture(mtcars)
# Save an R object as RDS
scratch_capture(list(a = 1, b = 2), to = "rds")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.