Skip to content

Commit

Permalink
date interval in x ax
Browse files Browse the repository at this point in the history
  • Loading branch information
cecicampanile committed Dec 20, 2024
1 parent 0097dd2 commit 19ca138
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 1 addition & 3 deletions R/plotInObservation.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ plotInObservation <- function(result,
# plot
if(length(unique(result$additional_level)) > 1 ){
p <- result |>
dplyr::mutate(additional_level = as.character(gsub("-01-01$","",as.Date(gsub(" to.*","",.data$additional_level))))) |>
dplyr::filter(.data$estimate_name == "count") |>
visOmopResults::scatterPlot(
x = "time_interval",
Expand All @@ -81,8 +80,7 @@ plotInObservation <- function(result,
p$data <- p$data |>
dplyr::arrange(time_interval) |>
dplyr::mutate(
show_label = seq_along(time_interval) %%
(10 * nrow(p$data|>dplyr::distinct(.data$omop_table))) == 0 # Show every 10th label
show_label = seq_along(time_interval) %% ceiling(nrow(p$data) / 20) == 0
)

p <- p +
Expand Down
23 changes: 13 additions & 10 deletions R/plotRecordCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,30 @@ plotRecordCount <- function(result,
y = "Number records",
x = "Date"
)

p$data <- p$data |>
dplyr::mutate(
time_interval = as.character(
gsub("-01-01$", "", as.Date(gsub(" to.*", "", time_interval)))
)
) |>
dplyr::arrange(time_interval) |>
dplyr::group_by(omop_table) |>
dplyr::mutate(
show_label = seq_along(time_interval) %%
(10 * nrow(p$data|>dplyr::distinct(.data$omop_table))) == 0 # Show every 10th label
)
show_label = if (dplyr::cur_group_id() == 1) {
seq_along(time_interval) %% ceiling(n() / 20) == 0
} else {
FALSE
}
) |>
dplyr::ungroup()

# Modify the plot
p <- p +
ggplot2::scale_x_discrete(
breaks = p$data$time_interval[p$data$show_label]
breaks = p$data$time_interval[p$data$show_label],
labels = p$data$time_interval[p$data$show_label]
) +
ggplot2::theme(
axis.text.x = ggplot2::element_text(angle = 90, hjust = 1, size = 8),
plot.margin = ggplot2::margin(t = 5, r = 5, b = 30, l = 5)
)


}else{
p <- result |>
visOmopResults::barPlot(x = "variable_name",
Expand Down
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 19ca138

Please sign in to comment.