Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Script Format for ggplot-ing Calibration Targets and Model Outcomes
- # This format should get adapted for each kind of calibration plot
- # that we want to visualize.
- # Feel free to share them with me whatever way is easiest -- a zip file
- # of R files would be perfectly fine!
- # dependencies
- library(ggplot2)
- library(MITUS)
- library(dplyr) # I assume we might need to do some re-shaping in dplyr?
- # Set Location
- # loc should be able to vary across the geographies that we have calibrated and
- # the rest of the code should still run.
- loc <- “US”
- # Read in Calibration Target and Model Outcomes Dataframes
- target_df <- readRDS(system.file(loc, “calibration_data”, “specificFileName.rds”, package = “MITUS”)
- outcomes_df <- readRDS(system.file(loc, “calibration_data”, “specificFileName2.rds”, package = “MITUS”)
- # If the target_df or outcomes_df has to be loaded or reshaped differently depending on whether
- # loc == 'US' or loc is a state, maybe we will need an if (loc == 'US') { ... } else { ... }
- # code block to handle data-loading and reshaping.
- # Data Formatting
- # Just let me know if you have any questions or need any help!
- # Plotting Code
- # Just let me know if you have any questions or need any help!
- # Make sure the ggplot is the last thing in this script so that it's the
- # object that gets returned when I put this inside a reactive or a
- # function in the Shiny code.
- ggplot() +
- geom_bar(data = targets_df, mapping = aes(x = year, etcetera...)) + # changes depending on what format we want
- geom_point(data = outcomes_df, mapping = aes(x = year, etcetera...)) + # changes depending on what format we want
- ggtitle() + # title of the plot
- theme_bw() + # makes the plots a little more professional looking with a white background instead of grey
- other_adjustments_as_necessary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement