From 624b95a370a8989fdec10b0a86916b259dc5ccb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonn=20R=C3=BCter?= Date: Mon, 4 Mar 2024 13:31:20 +0100 Subject: [PATCH] Remove NA values at read, filter for variables with 'percentile' suffix --- R/plotPercentiles.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/plotPercentiles.R b/R/plotPercentiles.R index 58c1998..ef6092c 100644 --- a/R/plotPercentiles.R +++ b/R/plotPercentiles.R @@ -40,10 +40,12 @@ plotPercentiles <- function(df, scenarios = NULL, variables = NULL) { # follow the format "Any|Variable|5.0th Percentile". The regular expressions below divide the variable name into the # prefix and the percentile specifier data <- df %>% + as.quitte(na.rm = TRUE) %>% mutate( "percentile" = stringr::str_extract(.data$variable, "[^\\|]+?$"), "variable" = gsub("\\|[^\\|]+$", "", .data$variable) ) %>% + filter(grepl(" Percentile$", .data$percentile)) %>% pivot_wider( names_from = "percentile", values_from = "value"