Remove code repetition in `specific_plotting_dynamic.R`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- r
- Domain
- data-visualization
Research direction
Start by reading specific_plotting_dynamic.R and identify the plotting functions that repeat observation and error-bar aesthetics. The work is done when a generic add_obs function adds observations and Obs_SD error bars, and those aesthetics are no longer repeated in the plotting layers.
Written by the indexing model from the issue text.
Description
In specific_plotting_dynamic.R, we can remove code repetition by putting all aes into the parent call (the ggplot()). This way we can remove the aes from the geom_line, geom_points and geom_errorbar, and put them in a more generic function that we would call similarly in all plotting functions:
Example, instead of:
p <- ggplot2::ggplot(
df_data,
ggplot2::aes(x = .data$Date, colour = .data$variable)
) +
ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) +
ggplot2::facet_wrap(~ .data$group_var, scales = "free") +
ggplot2::labs(shape = "Variable", colour = "Variable")
if ("Observed" %in% colnames(df_data)) {
p <- p + ggplot2::geom_point(
ggplot2::aes(y = .data$Observed, shape = .data$variable),
na.rm = TRUE
)
if ("Obs_SD" %in% colnames(df_data)) {
p <- p +
ggplot2::geom_errorbar(
ggplot2::aes(
ymin = .data$Observed - 2 * .data$Obs_SD,
ymax = .data$Observed + 2 * .data$Obs_SD,
shape = .data$version
),
na.rm = TRUE
)
}
}
We would do:
p <- ggplot2::ggplot(
df_data,
ggplot2::aes(x = .data$Date, colour = .data$variable, shape = .data$variable)
) +
ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) +
ggplot2::facet_wrap(~ .data$group_var, scales = "free") +
ggplot2::labs(shape = "Variable", colour = "Variable")
p <- add_obs(p)
With the add_obs function the function above that adds obs and obs_sd.
- Dominant language
- R
- Stars
- 1
- Forks
- 3
- Avg merge
- 9h 41m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SticsRPacks/CroPlotR
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SticsRPacks/CroPlotR#185 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
SticsRPacks/CroPlotR#180 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
SticsRPacks/CroPlotR#186 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 57/100
SticsRPacks/CroPlotR#181 ·
-
enhancement
Difficulty 3/5 Half a day Newbie friendliness 64/100
SticsRPacks/CroPlotR#173 ·
All issues in SticsRPacks/CroPlotR
Similar issues
-
1.7
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pharmaverse/admiral#3235 ·
Maintainers usually reply within 2 days
-
Typo: p.381Open
Difficulty 1/5 Under an hour Newbie friendliness 95/100
rmcelreath/rethinking#482 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day