[datatable-help] subset between data.table list and single data.table object

iembry iruckaE at mail2world.com
Mon Aug 12 15:02:01 CEST 2013


The following code represents the answer to my questions with assistance from
both this mailing list and stackoverflow:

big <- lapply(sitefiles,freadDataRatingDepotFiles)
big <- rbindlist(big)
setnames(big,c("y", "shift", "x", "stor", "site_no"))
big[, y:=as.numeric(y)]
big[, x:=as.numeric(x)]
big[, shift:=as.numeric(shift)]
big[, stor:=NULL]
big <- na.omit(big)
big[,y:=y+shift]
big[,shift:=NULL]
big[, site_no := sub(".exsa.rdb", "", basename(site_no), fixed=TRUE)]
setkey(big, site_no)

meaninterp <- big[aimjoin][,if(mean[1] > min(x)){interp1(x, y, xi = mean[1],
method ="linear")},by=site_no]
setnames(meaninterp,c("site_no", "mean"))

medianinterp <- big[aimjoin][,if(p50[1] > min(x)){interp1(x, y, xi = p50[1],
method ="linear")},by=site_no]
setnames(medianinterp,c("site_no", "median"))

meanextrap <- big[aimjoin][,if(mean[1] < min(x)){approxExtrap(x, y, xout =
mean[1], method ="linear")},by=site_no]

medianextrap <- big[aimjoin][,if(p50[1] < min(x)){approxExtrap(x, y, xout =
p50[1], method ="linear")},by=site_no]



--
View this message in context: http://r.789695.n4.nabble.com/subset-between-data-table-list-and-single-data-table-object-tp4673202p4673560.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list