cloud_s3_write | R Documentation |
Saves an R object to a designated location in the project's S3 storage. If no custom writing function is specified, the function will infer the appropriate writing method based on the file's extension.
cloud_s3_write(x, file, fun = NULL, ..., local = FALSE, root = NULL)
x |
An R object to be written to S3. |
file |
Path to a file relative to project folder root. Can contain only letters, digits, '-', '_', '.', spaces and '/' symbols. |
fun |
A custom writing function. If |
... |
Additional arguments to pass to the writing function |
local |
Logical, defaulting to |
root |
S3 path of the project root. This serves as the reference point
for all relative paths. When left as |
Invisibly returns NULL
after successfully writing the object to S3.
Here's how we identify a writing function based on file extension
.csv
: readr::write_csv
.json
: jsonlite::write_json
.rds
: base::saveRDS
.xls
: writexl::write_xlsx
.xlsx
: writexl::write_xlsx
.sav
: haven::write_sav
.xml
: xml2::write_xml
# write mtcars dataframe to mtcars.csv in data folder
cloud_s3_write(mtcars, "data/mtcars.csv")
cloud_s3_write(random_forest, "models/random_forest.rds")
# provide custom writing function with parameters
cloud_s3_write(c("one", "two"), "text/count.txt", writeLines, sep = "\n\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.