Questions tagged [r-collapse]

A package for advanced data transformation and statistical computing in R based on C/C++

9 questions
4
votes
1 answer

How to translate data.table code to collapse

I read about the collapse package recently and tried to translate the following data.table code to collapse to see if it's faster in real world examples. Here's my data.table…
der_grund
  • 1,898
  • 20
  • 36
2
votes
2 answers

Collapsing rows into lists for multiple columns based on identified duplicates in a group of other columns

I have a large dataset that is very similar to the following dummy dataset: df = data.frame(coursecode = c("WBPH001","WBPH001","WBPH001","WBPH058","WBAS007"), coursename = c("Mechanics","Mechanics","Mechanics", "Calculus…
Mink
  • 25
  • 3
2
votes
1 answer

Error: 'across' is not an exported object from 'namespace:collapse'

I am learning how to use the R package collapse to process the data. The syntax in collapse is similar to dplyr, with similar function names. Below is an example. Both code chunks work well. But since both packages contain the function across. I…
www
  • 38,575
  • 12
  • 48
  • 84
1
vote
2 answers

Grouped means in collapse package

I am trying to calculate grouped means using collapse package. Below is an example of what I am trying to achieve. library(data.table) library(collapse) data_1 <- as.data.table(airquality) var_means <- c( "Ozone", "Solar.R", …
Vitalijs
  • 938
  • 7
  • 18
1
vote
0 answers

R collapse package: apply a function to each element of a list or atomic vector

I'm switching to collapse R package for better speed. However, I'm struggling to translate purrr::map and its variants into collapse code. Couldn't figured out how to translate 1:2 %>% map(.x = ., .f = rnorm, n = 3) into relevant collapse code. My…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
1
vote
1 answer

collapse package: sum over two vectors but keep empty intersections

I would like to aggregate a vector/ matrix y by two variables a and b via the fsum function of the collapse package. fsum does not return values for empty intersections. Is there a way to keep empty intersection using the collapse package? I know…
A.Fischer
  • 596
  • 5
  • 11
0
votes
1 answer

summarise/collapse dataframe by row above or below based on conditions

Given: df <- data.frame(group = c(rep("a", 11), rep("b", 7)), dates = as.Date(c("2019-05-10", "2019-08-23", "2020-08-21", "2021-08-27", "2021-10-04", "2021-12-23", "2022-06-30", "2005-03-07", "2006-03-30",…
user63230
  • 4,095
  • 21
  • 43
0
votes
1 answer

R combine rows in data frame based on grouping variable when there are both numeric and character columns to be collapsed

I was provided with some interesting data that I need to aggregate/collapse/combine based on an ID field but different columns of the data frame contain both numeric and character vectors. The aggregate() function doesn't appear to work with…
Will Phillips
  • 805
  • 2
  • 10
  • 20
0
votes
0 answers

pivoting data frame using {collapse} package

I'm curious how to pivot a long data frame wide specifically using the {collapse} package. I like the performance aspect of the package, but I'm finding it hard to use at times for more mid-level data manipulation (e.g., tidyr::pivot_wider() ) An…
sebelly
  • 1
  • 1