Use addcolumn instead of mutate to add new columns in highcharter helper
Fixes an issue with dplyr 1.0:
x Input `year` can't be recycled to size 2.
ℹ Input `year` is `as.integer(queryStringToLabel(df$vc, pubDateOnly =
TRUE))`.
ℹ Input `year` must be size 2 or 1, not 58.
ℹ The error occured in group 1: vc = "textType = /Zeit.*/ & pubDate in
1990".
Change-Id: Ie3e3414e47bd8f6408270a53ef1d216a46f28824
diff --git a/R/highcharter-helper.R b/R/highcharter-helper.R
index 3933e88..2d4d7c1 100644
--- a/R/highcharter-helper.R
+++ b/R/highcharter-helper.R
@@ -4,6 +4,7 @@
#' \bold{Warning:} This function may be moved to a new package.
#'
#' @import highcharter
+#' @importFrom tibble add_column
#' @export
#'
#' @param df data frame like the value of a \code{\link{frequencyQuery}}
@@ -44,7 +45,7 @@
{ if(! as.alternatives) ipm(.) else RKorAPClient::percent(.) }
if (!"year" %in% colnames(df)) {
- df <- df %>% mutate(year = as.integer(queryStringToLabel(df$vc, pubDateOnly = TRUE)))
+ df <- df %>% add_column(year = as.integer(queryStringToLabel(df$vc, pubDateOnly = TRUE)))
}
if (!"condition" %in% colnames(df)) {
if (length(base::unique(df$query)) > 1) {
@@ -56,7 +57,7 @@
} else {
if (length(base::unique(queryStringToLabel(df$vc, excludePubDate = TRUE ))) > 1) {
title <- base::unique(df$query)
- df <- df %>% mutate(condition = queryStringToLabel(vc, excludePubDate = TRUE ))
+ df <- df %>% add_column(condition = queryStringToLabel(vc, excludePubDate = TRUE ))
} else {
df <- df %>% mutate(condition = query)
}