Dear list
I'm trying to access values within a data.table column by matching to
elements in a vector and replacing with corresponding elements in a second
vector. But I want to loop through specific column names also stored as a
character vector.
So something like:
DT <- data.table(A=seq(1:10),B=seq(1:10),C=seq(1:10))
cnm <- c("A", "B", "C")
before <- c(4, 5, 6)
after <- c(3, 7, 8)
nm <- cnm[i]
bfr <- before[i]
afr <- after[i]
DT[nm==bfr, nm:=afr]
I'm sure this is completely wrong because it didn't work.
So does anyone know how to correctly do this data.table solution?
Many thanks,
Manabu
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help