Remove code repetition in `specific_plotting_dynamic.R`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- r
- Ambito
- data-visualization
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- R
- Stelle
- 1
- Fork
- 3
- Merge medio
- 9h 41m
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di SticsRPacks/CroPlotR
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
SticsRPacks/CroPlotR#185 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
SticsRPacks/CroPlotR#180 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
SticsRPacks/CroPlotR#186 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 57/100
SticsRPacks/CroPlotR#181 ·
-
enhancement
Difficoltà 3/5 Mezza giornata Idoneità per principianti 64/100
SticsRPacks/CroPlotR#173 ·
Tutte le issue di SticsRPacks/CroPlotR
Issue simili
-
1.7
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
pharmaverse/admiral#3235 ·
I maintainer di solito rispondono entro 2 giorni
-
Typo: p.381Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
rmcelreath/rethinking#482 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno