Questions tagged [tidytable]

15 questions
24
votes
9 answers

How to name the list of the group_split output in dplyr

I have the following process which uses group_split of dplyr: library(tidyverse) set.seed(1) iris %>% sample_n(size = 5) %>% group_by(Species) %>% group_split() The result is: [[1]] # A tibble: 2 x 5 Sepal.Length Sepal.Width…
littleworth
  • 4,781
  • 6
  • 42
  • 76
2
votes
1 answer

R improve loop efficiency: Operating on columns that correspond to rows in a second dataframe

I have two data frames: dat <- data.frame(Digits_Lower = 1:5, Digits_Upper = 6:10, random = 20:24) dat #> Digits_Lower Digits_Upper random #> 1 1 6 20 #> 2 2 7 …
kzyat
  • 23
  • 4
2
votes
3 answers

Repeating certain part of string conditionally

I want to repeat certain part of string between ] and ; as the number of elements separated by ; preceding within []. So the desired output for [A1, AB11; A2, AB22] I1, C1 would be [A1, AB11] I1, C1; [A2, AB22] I1, C1. Any hints to start with.…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
1
vote
1 answer

R package: global import of equivalent package if preferred one fails

This question is inspired by the specific nature of tidytable as an intentional drop-in replacement for entire tidyverse packages and my own circumstances. I'm developing a couple of R packages at work that rely extensively on tidytable. The R…
Fons MA
  • 1,142
  • 1
  • 12
  • 21
1
vote
1 answer

R: turn string into variable names in `tidytable::complete()`

I have a tidytable that I would like to run complete on for a given set of columns, but for some reason that I can't figure out, usual methods that turn strings into variable names do not work: input <- tidytable::tidytable(a = sample(LETTERS, size…
mzuba
  • 1,226
  • 1
  • 16
  • 33
1
vote
1 answer

Bringing subtotals upfront in pivottabler::qpvt

Wondering how to bring subtotals upfront (First row and/or first column) in pivottabler::qpvt. library(pivottabler) qpvt( dataFrame = bhmtrains , rows = c("=", "TOC") , columns = c("TrainCategory", "PowerType") …
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
1
vote
1 answer

How to generate list objects within tidytable mutate rowwise?

I have the following want table, which are generated with rowwise() and mutate(). The main issue is that this solution is too slow. The actual dataset contains around 15,000,000 rows, and took around 6 hours to complete. What I hope to do is to…
Afiq Johari
  • 1,372
  • 1
  • 15
  • 28
1
vote
1 answer

How to optimize pasting single/multiple column names with its values based on some condition

I would like to paste column names with their values. It must be based on some condition (if statement) and it can be based on a single variable or multiple variables. Below is a small example showing how the data looks like. I would like to speed…
1
vote
2 answers

Updating rows of a data.frame with the rows of another data.frame

I want to update the rows of data.frame df1 with the rows of data.frame df2. Any hint? df1 <- data.frame( "V1" = LETTERS[1:4] , "V2" = 1:4 , "V3" = 7:10 ) df1 V1 V2 V3 1 A 1 7 2 B 2 8 3 C 3 9 4 D 4 10 df2 <- …
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
0
votes
0 answers

R bench package gives a strange error when I try to use the tidytable package

I'm trying to augment the benchmarks in this article with the tidytable package](https://www.tidyverse.org/blog/2023/04/performant-packages/#tools-of-the-trade). When I add tidytable to a benchmark, I get a strange error: Error: Each result must…
abalter
  • 9,663
  • 17
  • 90
  • 145
0
votes
3 answers

collapse: Modifying Columns by row along with combine values from multiple columns

I want to translate the following R code using tidytable into collapse: Advanced and Fast Data Transformation. tidytable Code library(tidytable) library(collapse) Out1 <- wlddev %>% mutate_rowwise.(New1 = sum(c_across.(PCGDP:GINI), na.rm =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
0
votes
1 answer

How to store nested data efficiently in R?

I want to manipulate, store and retrieve nested data in R, but to my surprise the nested data frame features a substantial increase in size: pacman::p_load(dplyr, tidytable) test3 <- tibble(ID = 1:1e5) %>% group_by(ID) %>% summarise(number =…
mzuba
  • 1,226
  • 1
  • 16
  • 33
0
votes
2 answers

tidyverse: filter with str_detect

I want to use filter command from dplyr along with str_detect. library(tidyverse) dt1 <- tibble( No = c(1, 2, 3, 4) , Text = c("I have a pen.", "I have a book.", "I have a pencile.", "I have a pen and a book.") ) dt1 # A tibble:…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
0
votes
5 answers

tidyverse: Comparing each row of a data.frame with a single row from another data.frame

I want to compare each row of df1 with a single row of df2 in tidy way. Any hint please. df1 <- structure( list( Q1 = c("a", "a") , Q2 = c("b", "a") , Q3 = c("a", "a") , Q4 = c("b", "a") ) , class =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
-1
votes
1 answer

Efficiently Binding rows of different attributes

I want to bind rows. However, few columns of the data.frames have different attributes. Like df1$caseid and df1$v001 have different attributes than df2$caseid and df2$v001. Wondering how can I can bind there…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309