- Assume that your AWS credential is set up in the local computer, its profile is
default, and the region is ap-northeast-1. If they are different, change them accordingly.
- At the beginning of your R file, read the credential information by
# set aws s3
signature <-
aws.signature::locate_credentials(
profile = "default",
region = "ap-northeast-1"
)
Sys.setenv(
"AWS_ACCESS_KEY_ID" = signature$key,
"AWS_SECRET_ACCESS_KEY" = signature$secret,
"AWS_DEFAULT_REGION" = signature$region
)
- Specify the bucket name as
bucket_name <- "mobileapp-rstudio"
- Then, you can directly read data from the bucket as
equilibrium <-
aws.s3::s3readRDS(
object = "output/simulate/equilibrium.rds",
bucket = bucket_name,
multipart = TRUE
)
- You can also save data as
aws.s3::s3saveRDS(
equilibrium,
object =
paste0(
prefix,
"equilibrium.rds"
),
bucket = bucket_name,
multipart = TRUE
)
- To read and write other formats of data, check the help of
aws.s3. There are functions like s3read_using.