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

Matthew Dowle mdowle at mdowle.plus.com
Tue Aug 6 11:17:13 CEST 2013


Hi,

This one isn't quite clear enough to answer quickly and easily. I'd 
expect there to be similar questions on Stack Overflow with code 
formatting, data in the question and benchmarks. Trick is how to filter 
the 708 data.table questions.

Try these 61 returned by "[data.table] join two" :

http://stackoverflow.com/search?q=%5Bdata.table%5D+join+two

Let us know if that doesn't help,  or raise a new question there. Also 
maybe try "[r] -[data.table] data.table"  with is:question or is:answer 
as well. That returns answers using data.table for questions which 
weren't about data.table.

Matthew

On 06/08/13 04:10, iembry wrote:
> 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.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130806/f56958b5/attachment.html>


More information about the datatable-help mailing list