@Jessica_Williams-Holt our Stanford project team mainly uses R so happy to help wherever we can. you can browse knitted files at https://stanfordfuturebay.github.io/, many of which make use of safegraph data. This is not meant to be “organized” in any fashion as it’s just internal navigation, but if folks have specific questions we can point to code that’s relevant.
@Derek_Ouyang_Stanford How are you exploding vertically the JSON columns of the “visitor_home_cbg”? I’m looking at the “safegraph_process_patterns_demo.html” and it looks like it’s happening in the normBG() function? I’m trying to do something that starts similar to your parks demo, where I want to count how many trips to parks there are from every block group, but I haven’t been able to expand the JSON column.
@Kate_Schertz_University_of_Chicago yes, in normBG, expandOrigins, specifically this:
patterns_data$visitor_home_cbgs[row] %>% fromJSON() %>% unlist() %>% as.data.frame() %>% rownames_to_column() %>% rename( origin_census_block_group = "rowname", origin_raw_visitor_counts_high = "." ) %>% mutate( # Dealing with the 2-4 visitor issue origin_raw_visitor_counts_low = ifelse( origin_raw_visitor_counts_high == 4, 2, origin_raw_visitor_counts_high ) )```
@Julia_Wagenfehr_Stanford we haven’t specifically calculated what @Kate_Schertz_University_of_Chicago is describing, but it’s been on our maybe-to-do for bay area. happy to keep in touch on what those results look like for your region.
thanks! I’ll try that. Is the code for “safegraph_process_patterns_functions.R” posted in full? I was just going to reference that but didn’t see it.
Can definitely share my results when I get somewhere!
@Kate_Schertz_University_of_Chicago thanks for pointing out we hadn’t published! it’s now at covid19
@Derek_Ouyang_Stanford just wanted to say thank you for making these resources available