3 From RDS files
3.1 Load an RDS-file
With the readRDS()
function, we can load data from R’s proprietary data format:
orders <- readRDS(file = "data/orders.rds")
If the original data was a tibble, as in this case, the loaded data will be, too:
orders
# A tibble: 2,874 x 68
order_id name order~1 app_id created_at updated_at test
<dbl> <chr> <dbl> <dbl> <dttm> <dttm> <lgl>
1 1.13e12 B1014 1014 580111 2019-05-24 12:59:16 2019-06-19 13:23:26 FALSE
2 1.13e12 B1015 1015 580111 2019-05-24 13:09:08 2019-06-21 14:40:07 FALSE
3 1.13e12 B1016 1016 580111 2019-05-24 13:22:41 2019-06-21 12:35:23 FALSE
4 1.13e12 B1017 1017 580111 2019-05-24 13:27:43 2019-06-21 14:27:18 FALSE
5 1.13e12 B1018 1018 580111 2019-05-24 13:36:46 2019-06-21 12:11:57 FALSE
6 1.13e12 B1019 1019 580111 2019-05-24 13:44:41 2019-06-21 14:37:21 FALSE
7 1.13e12 B1020 1020 580111 2019-05-24 13:49:21 2019-06-21 12:25:16 FALSE
8 1.13e12 B1021 1021 580111 2019-05-24 13:59:57 2019-06-21 11:49:47 FALSE
9 1.13e12 B1022 1022 580111 2019-05-24 14:43:53 2019-06-19 14:12:38 FALSE
10 1.13e12 B1023 1023 580111 2019-05-24 14:48:16 2019-06-21 15:54:24 FALSE
# ... with 2,864 more rows, 61 more variables: current_subtotal_price <dbl>,
# current_total_price <dbl>, current_total_discounts <dbl>,
# current_total_duties_set <dbl>, total_discounts <dbl>,
# total_line_items_price <dbl>, total_outstanding <dbl>, total_price <dbl>,
# total_tax <dbl>, total_tip_received <dbl>, taxes_included <lgl>,
# discount_codes <chr>, financial_status <chr>, fulfillment_status <chr>,
# source_name <chr>, landing_site <chr>, landing_site_ref <chr>, ...
3.2 Saving data to .rds
format
We can save any data frame to an .rds
file using the saveRDS()
function:
saveRDS(orders, file = "data/orders.rds")
3.3 Read more
Find more information in the R file format under the following links: