View source: R/patterns_lookup.R
| patterns_lookup | R Documentation |
This function, given a date or range of dates, will return a character vector of folder paths in the weekly (new or backfill) data you will need to run through list.files(pattern = '.csv.gz', full.names = TRUE) after downloading files (or just set list_files = TRUE. This is done because the subfolder after this is based on the hour the data is released, which can't be predicted ahead of time for future weeks.
patterns_lookup(
dates,
dir = NULL,
old_dir = NULL,
new_dir = NULL,
subfolder = "patterns",
silent = FALSE,
add_ma = 0,
patterns_backfill_date = "2021/08/02/22/",
old_date_split = lubridate::ymd("2021-07-11"),
old_bucket = "weekly-backfill",
new_bucket = "weekly",
key = NULL,
secret = NULL,
list_files = FALSE,
...
)
dates |
A vector of |
dir |
If specified, will append |
old_dir |
If specified, will append |
new_dir |
If specified, will append |
subfolder |
Which folder in the AWS bucket to look at. Will append "_backfill" for backfill data. Usually this is "patterns", "normalization_data", or "home_panel_summary". |
silent |
If specified, will omit the warning for using any dates after the package author last checked the consistency of the SafeGraph file structure. |
add_ma |
Also looks at the |
patterns_backfill_date |
Character variable with the folder structure for the most recent |
old_date_split |
Date indicating the last day on which "old" data is present, before switching to the "new" data structure. |
old_bucket, new_bucket |
The |
key |
A character string containing an AWS Access Key ID. If |
secret |
A character string containing an AWS Secret Access Key. |
list_files |
After creating folderpaths (and, possibly, downloading files), run each of them through |
... |
Arguments to be passed to |
# We have already downloaded all of AWS data into the working directory and just need to locate and load it
# (if we also wanted to download, we could leave off list_files and pass this to safegraph_aws,
# or add our key and secret here and it would download)
filelist <- patterns_lookup(lubridate::ymd('2020-9-01') + lubridate::days(0:100),
list_files = TRUE)
dt <- read_many_patterns(filelist = filelist, by = 'brands', expand_int = 'visits_by_day')
# Now let's get the normalization files
normlist <- patterns_lookup(lubridate::ymd('2020-9-01') + lubridate::days(0:100),
subfolder = 'normalization_stats',
list_files = TRUE)
norm <- read_many_csvs(filelist = normlist, makedate = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.