| read_shop | R Documentation |
This will open up a ZIP file from the SafeGraph shop and will read all of the data in, performing processing of the patterns files using read_patterns.
read_shop(
filename,
dir = ".",
keeplist = c("patterns", "normalization_stats.csv", "home_panel_summary.csv",
"visit_panel_summary.csv", "brand_info.csv"),
exdir = dir,
cleanup = TRUE,
by = NULL,
fun = sum,
na.rm = TRUE,
filter = NULL,
expand_int = NULL,
expand_cat = NULL,
expand_name = NULL,
multi = NULL,
naics_link = NULL,
select = NULL,
gen_fips = FALSE,
silent = FALSE,
start_date = NULL,
...
)
filename |
The filename of the |
dir |
The directory the file is in. |
keeplist |
Character vector of the files in the ZIP to read in. Use |
exdir |
Name of the directory to unzip to. |
cleanup |
Set to |
by, fun, na.rm, filter, expand_int, expand_cat, expand_name, multi, naics_link, select, gen_fips, silent, ... |
Other arguments to be passed to |
start_date |
An argument to be passed to |
The result will be a named list with each of the components of the data.
## Not run:
# In the working directory I have the file 'shop_file.zip' to read in
mydata <- read_shop('shop_file.zip',
# I only want some of the files
keeplist = c('patterns','home_panel_summary.csv'),
# For patterns, only keep these variables
select = c('raw_visit_counts', 'region', 'bucketed_dwell_times', 'location_name'),
# I want two aggregations of patterns - one of total visits by state ('region')
# and another by location_name that has the dwell times for each brand
multi = list(
list(name = 'all',
by = 'region'),
list(name = 'location_dwells',
by = 'location_name',
expand_cat = 'bucketed_dwell_times',
expand_name = 'bucketed_times')
),
# Be sure to specify start_date for read_shop
start_date = lubridate::ymd('2020-03-01'))
# The result is a list with two items- patterns and home_panel_summary.csv
# patterns itself is a list with two data.tables inside - 'all' and 'location_name',
# aggregated as given.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.