-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExercise_13.R
More file actions
32 lines (24 loc) · 793 Bytes
/
Exercise_13.R
File metadata and controls
32 lines (24 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Exercise 13
library(tidyverse)
# let's recreate exercise 6, but use a fixed list of files.
files <- c("data/ae_attendances/2019-01-01.csv",
"data/ae_attendances/2019-02-01.csv",
"data/ae_attendances/2019-03-01.csv",
"data/ae_attendances/2019-04-01.csv")
# note that the last file does not exist
file.exists(files)
col_types <- cols(
period = col_date(format = ""),
org_code = col_character(),
type = col_character(),
attendances = col_double(),
breaches = col_double(),
admissions = col_double()
)
# now, first try running the following:
map(files, read_csv, col_types = col_types)
# try to fix the above line with safely
map(files, safely(read_csv), col_types = col_types) %>%
transpose() %>%
pluck("result") %>%
reduce(bind_rows)