-
Notifications
You must be signed in to change notification settings - Fork 0
Encountering issues?
On this page we are documenting issues that we've run into while adapting the 'data-gen' and 'vis' scripts to different indicators/data sources. If you are having an issue, you can see if your issue/solution is recorded here. If not, please reach out and we can try to work through the issue.
This is a warning message you are likely getting when trying to run/knit the 'vis' script. It shouldn't cause any issues - just a warning in RStudio. You can ignore this for now.
This issue is because the source code for the chart functions that you refer to around lines 330 (tract-template) or 340 (pums-template) is dependent on knitting - relying on the code at line 22 (both templates). If you wish to run the code to see the visualizations before you knit the full HTML or DOCX files, you will need to adjust the source code by using the full GitHub address (which is unique to your file directory system).
Once you've added the full path to equity-tracker-chart-functions.R
(likely including your C drive), you can comment out the shortened source('equity-tracker-chart-functions.R')
and run the full chunk. If you do this, remember to un-comment the shorted source code before you knit the RMarkdown to generate the HTML and DOCX. An alternative would be to run this code chunk line by line, skipping over the shorted source code. This may be confusing - reach out if you still need clarification.
This is an error message that is not allowing you to run/knit the 'vis' script. It is likely because of the way in which the data frame is formatted. To resolve this issue you will have to return to the 'data-gen' script and check to see how you transformed your data before saving it as an .rda. You are likely encountering this issue because you needed to use group_by()
and summarise()
when transforming your data by aggregating categories (for example, grouping 'Cost Burdened 30-50%' and 'Cost Burdened 50%+' to 'Cost Burdened (More than or Equal to 30%)' and summarizing the measure. If this is the case, use .groups = 'drop'
within the summarise()
argument when generating your .rda. Once the group_by()
and summarise()
transformation is revised, you should be able to save your .rda and return to the 'vis' script to try running/knitting the charts.
Example:
new_data <- old_data %>% group_by(simplified_cost_burden) %>% summarise(total_perc=sum(percent), .groups='drop')
If you need to update and recreate the visuals after making edits, you will need to re-knit the revised 'vis' script (to HTML). After you knit it and the .html outputs are in the correct folder in the Y drive, you will need to run the two chunks at the end of the 'vis' script. You may encounter an error because the directories may not be saved in the environment. This will require you to run the part of the code where you set the directory variables (base_dir
, theme_dir
, ind_dir
) - lines 171-73 in the vis template scripts. Once you run these lines, you can proceed with running the chunks under the 'Transfer files' heading.
If you are re-knitting/re-running multiple scripts to update visuals you will need to reset the directory variables (base_dir
, theme_dir
, ind_dir
) each time so that you aren't saving outputs to the wrong thematic/indicator folders. This process would be:
- knit script #1, run directory variable chunk in script #1, run two code chunks at the bottom of the script #1
- knit script #2, run directory variable chunk in script #2, run two code chunks at the bottom of the script #2
If you have tract-level (place-based) data and there are some years missing, this will impact the x-axis of the line chart. To rectify this copy code from lines 575-621 and paste them in your vis code as its own section above the "# Create Facet Line Chart" section. Adjust the standard_base_year as needed to match the start year of the other facet line charts in your visualizations.
Then later on in your script, when you define the df for the line chart in the following code chunk: use df = dplyr::filter(df2, data_year %in% c("2010", "2015", "2020"))
- inserting the correct years for your data.
*This should not be an issue for PUMS data, as the view has been updated to include NULL rows for missing data (years/equity groups)
If the data for your map needs a log transformation to make the map color scale meaningful, update your map code in these approximate locations using the lines in the vis-tract-template file as reference:
- Line 189, add
summary(log(1+tract_data_plus_zero))
to set themax_value
for the log transformation - Line 194, use
tract_data_plus_zero<-append(data_tract$estimate,0)
without any edits - Line 200, for
psrc_palette
, update domain to:domain = c(min(log(1+tract_data_plus_zero),na.rm = TRUE),max_value, NA))
- Line 203, when updating
var_name
, add an * after the new name - Line 237, for
addPolygons
, update fillColor to:fillColor = psrc_palette(log(1+tract_data_plus_zero))
- Line 247, for
addLegend_decreasing
, update values to:values = c(min(log(1+tract_data_plus_zero),na.rm = TRUE),max_value, NA),
and updatelabFormat
tolabFormat = labelFormat(transform = function(x) round(exp(1+x),-1))
- Below sources at line 270 add, * Note: color ramp uses log scale