s3_write {botor}R Documentation

Write an R object into S3

Description

Write an R object into S3

Usage

s3_write(x, fun, uri, compress = c("none", "gzip", "bzip2", "xz"), ...)

Arguments

x

R object

fun

R function with file argument to serialize x to disk before uploading, eg write.csv, write_json, stream_out or saveRDS

uri

string, URI of an S3 object, should start with s3://, then bucket name and object key

compress

optionally compress the file before uploading to S3. If compression is used, it's better to include the related file extension in uri as well (that is not done automatically).

...

optional further arguments passed to fun

Note

The temp file used for this operation is automatically removed.

Examples

## Not run: 
s3_write(mtcars, write.csv, 's3://botor/example-data/mtcars.csv', row.names = FALSE)
s3_write(mtcars, write.csv2, 's3://botor/example-data/mtcars.csv2', row.names = FALSE)
s3_write(mtcars, jsonlite::write_json, 's3://botor/example-data/mtcars.json', row.names = FALSE)
s3_write(mtcars, jsonlite::stream_out, 's3://botor/example-data/mtcars.jsonl', row.names = FALSE)
s3_write(mtcars, saveRDS, 's3://botor/example-data/mtcars.RDS')

## compress file after writing to disk but before uploading to S3
s3_write(mtcars, write.csv, 's3://botor/example-data/mtcars.csv.gz',
  compress = 'gzip', row.names = FALSE)
s3_write(mtcars, write.csv, 's3://botor/example-data/mtcars.csv.bz2',
  compress = 'bzip2', row.names = FALSE)
s3_write(mtcars, write.csv, 's3://botor/example-data/mtcars.csv.xz',
  compress = 'xz', row.names = FALSE)

## End(Not run)

[Package botor version 0.4.0 Index]