From 12bcf8535e1acb94e74ef8a924e751cf9970ced8 Mon Sep 17 00:00:00 2001 From: Holger Brandl Date: Thu, 1 Jun 2017 12:59:27 +0200 Subject: [PATCH] added `first_group` --- R/core_commons.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/core_commons.R b/R/core_commons.R index 18d9134..f2475e5 100644 --- a/R/core_commons.R +++ b/R/core_commons.R @@ -396,6 +396,15 @@ get_col = function(data, col_index) data[, col_index] ## also could use magrittr extract_col = function(x, col_index=1, sep="_", num_cols=10){ str_split_fixed(x, sep, num_cols)[, col_index]} +## Extract the first group of a grouped data-frame +first_group = function(groupedDF){ + # groupedDF = geneLists + # groupedDF = iris %>% group_by(Species) + # https://stackoverflow.com/questions/33775239/emulate-split-with-dplyr-group-by-return-a-list-of-data-frames + (groupedDF %>% do(data = (.)) %$% map(data, identity))[[1]] +} + + reload_dplyr <- function(){ unloadNamespace('tidyr') -- GitLab