diff --git a/R/plotInObservation.R b/R/plotInObservation.R index 9fc6227..f0ae005 100644 --- a/R/plotInObservation.R +++ b/R/plotInObservation.R @@ -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", @@ -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 + diff --git a/R/plotRecordCount.R b/R/plotRecordCount.R index 0af399e..dbfbabb 100644 --- a/R/plotRecordCount.R +++ b/R/plotRecordCount.R @@ -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", diff --git a/man/figures/README-unnamed-chunk-3-1.png b/man/figures/README-unnamed-chunk-3-1.png index bb2cd14..e25b42c 100644 Binary files a/man/figures/README-unnamed-chunk-3-1.png and b/man/figures/README-unnamed-chunk-3-1.png differ diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index a03d54b..582a986 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png index b357e36..bc9460b 100644 Binary files a/man/figures/README-unnamed-chunk-6-1.png and b/man/figures/README-unnamed-chunk-6-1.png differ