From 3f1939095085aa921d4a03dcda510420de1a950e Mon Sep 17 00:00:00 2001 From: levisc8 Date: Mon, 30 Sep 2019 23:53:58 +0200 Subject: [PATCH 1/4] bump to tidyr 1.0.0 --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/browse.R | 33 +++++++++------------------------ 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d47f3d9..1e17b60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,7 @@ Imports: stats (>= 3.3.0), stringr (>= 1.2.0), tibble (>= 1.4.2), - tidyr (>= 0.6.1), + tidyr (>= 1.0.0), utils (>= 3.3.0) License: MIT + file LICENSE Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index e085c55..fe55c7f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -73,6 +73,7 @@ importFrom(stringr,str_match) importFrom(stringr,str_split) importFrom(tibble,as_tibble) importFrom(tidyr,nest) +importFrom(tidyr,one_of) importFrom(utils,View) importFrom(utils,bibentry) importFrom(utils,browseURL) diff --git a/R/browse.R b/R/browse.R index 0286783..1773e78 100644 --- a/R/browse.R +++ b/R/browse.R @@ -231,7 +231,7 @@ vars_spell <- function(select_columns, columns_full_tab, possibleargs){ # expand table (to nest/unnest taxonomic info) #' @importFrom dplyr group_by %>% -#' @importFrom tidyr nest +#' @importFrom tidyr nest one_of #' @noRd taxa_nest <- function(x, full_tbl){ @@ -255,30 +255,15 @@ taxa_nest <- function(x, full_tbl){ if(!any(names(x) %in% taxas)) out <- unique(summary_table[ ,names(x), drop = FALSE]) - # if only ONE of the taxonomic variables is provided - if(sum(names(x) %in% taxas) == 1){ - - - nested_var <- taxas[which(taxas %in% names(x))] - out <- x %>% - dplyr::group_by(.dots = setdiff(names(x), taxas)) %>% - tidyr::nest(key_col = nested_var, nest_cols = nested_var) - # Names of taxonomic lists - names(out)[2] <- nested_var - } - # if more than ONE of the taxonomic variables is provided, - # then these multiple taxonomic variables are group under "taxas" - if(sum(names(x) %in% taxas) > 1){ - - # nest data set - out <- x %>% - dplyr::group_by(.dots = setdiff(names(x),taxas)) %>% - tidyr::nest(.key = taxas) - # Names of taxonomic lists - names(out$taxas) <- paste0("taxa_project_#_", out$proj_metadata_key) - - } + # nest data set + out <- x %>% + dplyr::group_by(.dots = setdiff(names(x),taxas)) %>% + tidyr::nest(taxas = tidyr::one_of(taxas)) + # Names of taxonomic lists + names(out$taxas) <- paste0("taxa_project_", out$proj_metadata_key) + + return(out) From acdd0ec957ba23cfb3affb41db5320b8b1c277fa Mon Sep 17 00:00:00 2001 From: levisc8 Date: Mon, 30 Sep 2019 23:53:58 +0200 Subject: [PATCH 2/4] woops --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/browse.R | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d47f3d9..1e17b60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,7 @@ Imports: stats (>= 3.3.0), stringr (>= 1.2.0), tibble (>= 1.4.2), - tidyr (>= 0.6.1), + tidyr (>= 1.0.0), utils (>= 3.3.0) License: MIT + file LICENSE Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index e085c55..fe55c7f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -73,6 +73,7 @@ importFrom(stringr,str_match) importFrom(stringr,str_split) importFrom(tibble,as_tibble) importFrom(tidyr,nest) +importFrom(tidyr,one_of) importFrom(utils,View) importFrom(utils,bibentry) importFrom(utils,browseURL) diff --git a/R/browse.R b/R/browse.R index 0286783..f7699c9 100644 --- a/R/browse.R +++ b/R/browse.R @@ -231,7 +231,7 @@ vars_spell <- function(select_columns, columns_full_tab, possibleargs){ # expand table (to nest/unnest taxonomic info) #' @importFrom dplyr group_by %>% -#' @importFrom tidyr nest +#' @importFrom tidyr nest one_of #' @noRd taxa_nest <- function(x, full_tbl){ @@ -261,8 +261,8 @@ taxa_nest <- function(x, full_tbl){ nested_var <- taxas[which(taxas %in% names(x))] out <- x %>% - dplyr::group_by(.dots = setdiff(names(x), taxas)) %>% - tidyr::nest(key_col = nested_var, nest_cols = nested_var) + dplyr::group_by(.dots = setdiff(names(x), taxas)) %>% + tidyr::nest(taxas = tidyr::one_of(taxas)) # Names of taxonomic lists names(out)[2] <- nested_var } @@ -274,9 +274,9 @@ taxa_nest <- function(x, full_tbl){ # nest data set out <- x %>% dplyr::group_by(.dots = setdiff(names(x),taxas)) %>% - tidyr::nest(.key = taxas) + tidyr::nest(taxas = tidyr::one_of(taxas)) # Names of taxonomic lists - names(out$taxas) <- paste0("taxa_project_#_", out$proj_metadata_key) + names(out$taxas) <- paste0("taxa_project_", out$proj_metadata_key) } From c71d298bd0b4209a1208386d760a4044047206aa Mon Sep 17 00:00:00 2001 From: levisc8 Date: Tue, 1 Oct 2019 00:31:50 +0200 Subject: [PATCH 3/4] final attempt for tonight --- R/browse.R | 3 --- 1 file changed, 3 deletions(-) diff --git a/R/browse.R b/R/browse.R index 194605c..0493294 100644 --- a/R/browse.R +++ b/R/browse.R @@ -287,9 +287,6 @@ taxa_nest <- function(x, full_tbl){ # Names of taxonomic lists names(out$taxas) <- paste0("taxa_project_", out$proj_metadata_key) - ->>>>>>> 3f1939095085aa921d4a03dcda510420de1a950e - return(out) } From f32e07a95796b35cccdb48e5e85c6e98e1d35419 Mon Sep 17 00:00:00 2001 From: levisc8 Date: Tue, 1 Oct 2019 01:25:58 +0200 Subject: [PATCH 4/4] delete accidental insertions --- R/browse.R | 7 ------- 1 file changed, 7 deletions(-) diff --git a/R/browse.R b/R/browse.R index 0493294..0b44b66 100644 --- a/R/browse.R +++ b/R/browse.R @@ -280,13 +280,6 @@ taxa_nest <- function(x, full_tbl){ } - # nest data set - out <- x %>% - dplyr::group_by(.dots = setdiff(names(x),taxas)) %>% - tidyr::nest(taxas = tidyr::one_of(taxas)) - # Names of taxonomic lists - names(out$taxas) <- paste0("taxa_project_", out$proj_metadata_key) - return(out) }