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

iembry iruckaE at mail2world.com
Tue Aug 6 05:10:02 CEST 2013


Hi, I started this new topic thread as now I'm concentrating on the
subsetting portion of the R code.

I have the R objects aimall and getratingsmore. aimall is a data.table with
the column names "mean" and "p50" and it is 59 rows long, but I have
truncated it for this question & getratingsmore is a list of 59 data.table
objects with the column names "y" and "x".

dput(aimall)
structure(list(mean = c(3882.65, 819.82, 23742.37), p50 = c(1830, 382,
10400)), .Names = c("mean", "p50"), row.names = c(NA, -3L), class =
c("data.table", "data.frame"), .internal.selfref = <pointer: 0x1a5c628>)


dput(getratingsmore)
list(structure(list(y = c(14.8, 14.81, 14.82), x = c(7900, 7920, 7930)),
.Names = c("y", "x"), row.names = c(NA, 
-2721L), class = c("data.table", "data.frame"), .internal.selfref =
<pointer: 0x1a5c628>), structure(list(y = c(4, 4.01, 4.02), x = c(21, 21,
22)), .Names = c("y", "x"), row.names = c(NA, -1464L), class =
c("data.table", "data.frame"), .internal.selfref = <pointer: 0x1a5c628>),
structure(list(y = c(73.05, 73.06, 73.07), x = c(70, 76, 82)), .Names =
c("y", "x"), row.names = c(NA, -1996L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x1a5c628>))


I have used the following code to attempt to subset getratingsmore and the
dput follows:

mp <- lapply(seq_along(dailyvaluesneednew$site_no), function(u)
{ifelse(aim[1]$mean[u] < min(getratingsmore[[u]]$x), subset(getratings[[u]],
aim[1]$mean[u] > min(getratingsmore[[u]]$x) & aim[1]$mean[u], aim[u]$mean[u]
> min(getratingsmore[[u]]$x)), aim[1]$mean[u])})

dput(mp)
list(list(NULL), 819.82, 23742.37)


I had created a key for aimall, but then the data.table was sorted and it
lost its connection to getratingsmore. Right now, aimall and getratingsmore
represent the same station in their current order. 

Is there any way to set a key to each row of aimall that will match each
data.frame of getratingsmore?

Is there a way to subset in the way that I have described without a key
using data.table?

I want to know which stations have a mean and p50 value < the lowest "x" in
each station data.frame of getratingsmore so that those stations can then
use extrapolation in the next step.

I also want to know which stations ahve a mean and p50 value > the lowest
"x" in each station data.frame of getratingsmore so that those stations can
then use interpolation in the next step.

Thank you.

Irucka



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


More information about the datatable-help mailing list