Skip to main content
Filter by
Sorted by
Tagged with
4 votes
5 answers
366 views

I am looking for an efficient way to compute the union and intersection of time intervals (start–stop format) by group (id), while keeping the covariates associated with each interval. Each patient (...
Alex's user avatar
  • 43
1 vote
1 answer
111 views

This is very closely related to: Adding new columns to a data.table by-reference within a function not always working How do you make setalloccol work on data tables (data.table_1.16.0) that are a ...
Alex's user avatar
  • 16.1k
0 votes
0 answers
60 views

I have a data.table with a column name that matches a vector with the same name: library(data.table) dt <- data.table("colA" = c(1:5), "colB" = LETTERS[1:5]) colA = c(1,3) I ...
ken's user avatar
  • 335
3 votes
4 answers
237 views

I have a dataset where the column to unnest contains data with unequal rows and columns rather than data with equal dimensions. I'm looking for a fast approach to unnest this dataset using data.table. ...
Steve's user avatar
  • 107
5 votes
5 answers
342 views

I am trying to do a sum over a vector CountB by "filtering" a DTX with multiple criteria same location1, same location2, and only rows with CountA strictly less than the CountA in that ...
Mohit's user avatar
  • 597
4 votes
6 answers
446 views

Let's say I have a data.table that looks like this: library(data.table) dt <- rowwiseDT( group=, a=, b=, "a", 1, 10, "a", 10, 1, "a", 9, 9, &...
sjenkins's user avatar
1 vote
0 answers
89 views

For instance, if I do this: library(data.table) foo <- data.table(a=c(1,2)) foo[a==1,,] I get > a > <num> > 1: 1 If I do this instead: a <- 1 foo[a==a,,] I get &...
umbe1987's user avatar
  • 3,698
4 votes
0 answers
251 views

I am new to data.table and would like to figure out the best way of doing the following: I would like to write a function that takes multiple column names as arguments. I am fine needing the pass the ...
ZyzotPerplex's user avatar
3 votes
2 answers
116 views

Consider the data frame id <-c(1,1,1,2,2,3,3,3,3) x1 <-c("no","yes","yes","no","no","no","no","no","yes")...
T Richard's user avatar
  • 673
1 vote
1 answer
140 views

I have a dataset that looks like this: library(data.table) library(ggplot2) set.seed(123) years <- 2010:2020 max_colors <- 50 data <- data.frame() for (year in years) { n_colors <- ...
stats_noob's user avatar
  • 6,845
0 votes
0 answers
42 views

I'm using R to classify consultation notes on a number of criteria. My code works when I run it row by row, but not when I try to run it with data.table operators (I've tried data.frame transform ...
menimoy's user avatar
4 votes
2 answers
146 views

I am try to split Granges to specific n of bins, usually, GenomicRanges::tile could work for this. However, my Granges has some gaps, for example: # if (!require("BiocManager", quietly = ...
zhang's user avatar
  • 689
2 votes
2 answers
91 views

I have two data.tables. The first (dt1) has N sets of observations per individual. The second (dt2) contains pairings of two individuals. I want the output (dt3) to contain columns of observations for ...
tpotter's user avatar
  • 23
16 votes
1 answer
503 views

Is there a way to tell data.table to look for an external variable instead of a column name, just like what you can do with the .env pronoun in dplyr? Imagine you have a dataframe with the column name ...
Noskario's user avatar
  • 906
5 votes
1 answer
121 views

library(data.table) DateTime<-as.POSIXct(c("2025-05-16 00:00:02 CDT", "2025-05-16 00:00:03 CDT", "2025-05-16 00:00:06 CDT", "2025-05-16 00:00:07 CDT")) ...
Aelian's user avatar
  • 757
1 vote
1 answer
126 views

The as.data.frame (xy = true) function in terra has been used before for raster data to data frame conversion. Suddenly I realised that I could use it in conjunction with the data.table package. I'm ...
Breeze's user avatar
  • 586
4 votes
3 answers
143 views

Let's say I have the following dataframe df1=read.table(text="ID POSITION S1 S2 1 1 10 10 1 2 20 0 1 3 10 0 1 4 20 0 1 5 10 50 2 1 10 0 2 2 20 10 2 3 20 10 2 4 20 10 2 5 20 ...
Gabriel G.'s user avatar
5 votes
3 answers
218 views

I'm trying to filter a data.table by comparing a column to an external R variable using the "two‐dot" pronoun (..), but I keep getting Error in `[.data.table`(dt, reg == ..reg) : object '.....
Macosso's user avatar
  • 1,511
1 vote
2 answers
168 views

Looking for the current most efficient approach in either R, python or c++ (with Rcpp). Taking an example with financial data, df time bid ask time_msc ...
gaut's user avatar
  • 6,028
1 vote
2 answers
82 views

Having a data.table like the following: a <- data.table(col1 = c(1, 2, 3, NA, NA), col2 = c(NA, NA, NA, 4, 5), col3 = c("a", "b", "c", ...
s.cerioli's user avatar
  • 181
3 votes
1 answer
148 views

I'm trying to read through multiple compressed tables that are 5GB+ in size in R, and because I have insufficient memory to read them into memory all at once I need to process them one chunk at a time,...
Alex Petty's user avatar
5 votes
1 answer
239 views

I'm working with a very large dataset containing CWD (Cumulative Water Deficit) and EVI (Enhanced Vegetation Index) measurements across different landcover types. The current code uses LOESS ...
Shunrei's user avatar
  • 339
1 vote
1 answer
103 views

I'd like to join tabular data to a raster using the current cell values as a key. Is there an way to do this with large rasters (100M- 1B cells)? Maybe there's something obvious in terra:: but nothing ...
gvan's user avatar
  • 585
6 votes
2 answers
223 views

In a database containing firm and patent class values, I want to calculate the following variables: Technological abandonment: Number of previously active technological patent classes abandoned ...
lovestacksflow's user avatar
0 votes
1 answer
158 views

I have written the following code in R which adds a date (dp_date) and creates a flag (dp_flag) in dt.all sample based on columns from data tables dt.all and Info. The issue that I cannot create ...
Bambeil's user avatar
  • 320

1
2 3 4 5
277