Displaying 11 results from an estimated 11 matches for "setcolord".
Did you mean:
setcolor
2024 Dec 11
1
Cores hang when calling mcapply
...ut1_missing <- setdiff(all_cols, names(out1))
> out2_missing <- setdiff(all_cols, names(out2))
>
> # Add missing columns with 0
> for (col in out1_missing) out1[, (col) := 0]
> for (col in out2_missing) out2[, (col) := 0]
>
> # Ensure column order alignment if needed
> setcolorder(out1, all_cols)
> setcolorder(out2, all_cols)
>
> # Combine by ID_Key (since they share same columns now)
> final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
>
> # Step E: If needed, summarize across ID_Key to sum presence
> indicators
> final_res...
2024 Dec 12
1
Cores hang when calling mcapply
...;, .x, recycle0 = TRUE), -ID_Key))
all_cols <- unique(c(names(out1), names(out2)))
out1_missing <- setdiff(all_cols, names(out1))
out2_missing <- setdiff(all_cols, names(out2))
for (col in out1_missing) out1[, (col) := 0]
for (col in out2_missing) out2[, (col) := 0]
setcolorder(out1, all_cols)
setcolorder(out2, all_cols)
final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
final_result <- as_tibble(final_dt[, lapply(.SD, sum, na.rm = TRUE), by = ID_Key, .SDcols = setdiff(names(final_dt), "ID_Key")])
Worth noting however:...
2024 Dec 11
1
Cores hang when calling mcapply
...ut1_missing <- setdiff(all_cols, names(out1))
> out2_missing <- setdiff(all_cols, names(out2))
>
> # Add missing columns with 0
> for (col in out1_missing) out1[, (col) := 0]
> for (col in out2_missing) out2[, (col) := 0]
>
> # Ensure column order alignment if needed
> setcolorder(out1, all_cols)
> setcolorder(out2, all_cols)
>
> # Combine by ID_Key (since they share same columns now)
> final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
>
> # Step E: If needed, summarize across ID_Key to sum presence
> indicators
> final_resu...
2024 Dec 11
1
Cores hang when calling mcapply
...;- setdiff(all_cols, names(out2))
> > >
> > > # Add missing columns with 0
> > > for (col in out1_missing) out1[, (col) := 0]
> > > for (col in out2_missing) out2[, (col) := 0]
> > >
> > > # Ensure column order alignment if needed
> > > setcolorder(out1, all_cols)
> > > setcolorder(out2, all_cols)
> > >
> > > # Combine by ID_Key (since they share same columns now)
> > > final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
> > >
> > > # Step E: If needed, summarize ac...
2024 Dec 12
1
Cores hang when calling mcapply
...ey))
> ? ? all_cols <- unique(c(names(out1), names(out2)))
> ? ? out1_missing <- setdiff(all_cols, names(out1))
> ? ? out2_missing <- setdiff(all_cols, names(out2))
> ? ? for (col in out1_missing) out1[, (col) := 0]
> ? ? for (col in out2_missing) out2[, (col) := 0]
> ? ? setcolorder(out1, all_cols)
> ? ? setcolorder(out2, all_cols)
> ? ? final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
> ? ? final_result <- as_tibble(final_dt[, lapply(.SD, sum, na.rm = TRUE), by = ID_Key, .SDcols = setdiff(names(final_dt), "ID_Key")])
>
>...
2024 Dec 11
1
Cores hang when calling mcapply
...s(out1))
> > out2_missing <- setdiff(all_cols, names(out2))
> >
> > # Add missing columns with 0
> > for (col in out1_missing) out1[, (col) := 0]
> > for (col in out2_missing) out2[, (col) := 0]
> >
> > # Ensure column order alignment if needed
> > setcolorder(out1, all_cols)
> > setcolorder(out2, all_cols)
> >
> > # Combine by ID_Key (since they share same columns now)
> > final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
> >
> > # Step E: If needed, summarize across ID_Key to sum presence
&g...
2023 Jan 26
2
Resumen de R-help-es, Vol 167, Envío 10
...= sample(c("1","0"), 10, TRUE)
, V3b = sample(c("1","0"), 10, TRUE)
, V4a = sample(c("1","0"), 10, TRUE)
, V4b = sample(c("1","0"), 10, TRUE))
dt[,":="(seq=.I)]
setcolorder(dt,"seq")
dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
value.name="vl")
dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
paste0(x,collapse="|")...
2024 Dec 11
1
Cores hang when calling mcapply
...ut1_missing <- setdiff(all_cols, names(out1))
> out2_missing <- setdiff(all_cols, names(out2))
>
> # Add missing columns with 0
> for (col in out1_missing) out1[, (col) := 0]
> for (col in out2_missing) out2[, (col) := 0]
>
> # Ensure column order alignment if needed
> setcolorder(out1, all_cols)
> setcolorder(out2, all_cols)
>
> # Combine by ID_Key (since they share same columns now)
> final_dt <- rbindlist(list(out1, out2), use.names = TRUE, fill = TRUE)
>
> # Step E: If needed, summarize across ID_Key to sum presence
> indicators
> final_resu...
2024 Dec 11
2
Cores hang when calling mcapply
Hi R users.
Apologies for the lack of concrete examples because the dataset is large, and it being so I believe is the issue.
I multiple, very large datasets for which I need to generate 0/1 absence/presence columns
Some include over 200M rows, with two columns that need presence/absence columns based on the strings contained within them, as an example, one set has ~29k unique values and the
2023 Jan 27
0
Resumen de R-help-es, Vol 167, Envío 10
..., V3b = sample(c("1","0"), 10, TRUE)
> > > , V4a = sample(c("1","0"), 10, TRUE)
> > > , V4b = sample(c("1","0"), 10, TRUE))
> > > dt[,":="(seq=.I)]
> > > setcolorder(dt,"seq")
> > >
> > > dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> > > value.name="vl")
> > > dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> > > dt2 <- dcast...
2023 Jan 28
0
Resumen de R-help-es, Vol 167, Envío 10
..., V3b = sample(c("1","0"), 10, TRUE)
> > > , V4a = sample(c("1","0"), 10, TRUE)
> > > , V4b = sample(c("1","0"), 10, TRUE))
> > > dt[,":="(seq=.I)]
> > > setcolorder(dt,"seq")
> > >
> > > dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> > > value.name="vl")
> > > dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> > > dt2 <- dcast...