Hi together,<div><br></div><div>I run a Monte Carlo simulation on a data.table and do that currently with a loop: on every run, I choose a subset of rows subject to certain criteria and from those rows I take a random element. Currently, I do the following: Let's say I have funds from two regions ("eu" and "us") and I want to choose a random fund from "eu" (could be "us" in the next run and a different region in the third):</div>
<div><div><br></div><div>library(data.table)</div><div>rawData <- data.table(fundID = letters,</div><div> compGeo = rep(c("us", "eu"), each=13))</div><div>setkey(rawData, "compGeo")</div>
<div>intDT <- rawData[J("eu"), mult="all"]</div><div>intDT[<a href="http://sample.int">sample.int</a>(nrow(intDT), size=1)]</div><div><br></div><div>So my idea is to just give the user the option mult="random", which does this in one step. What do you think about that feature request? </div>
<div><br></div><div>With respect to the implementation: I changed a few lines in the function '[.data.table' and got this to run on my locale data.table version, so I guess I could implement it (as far as I can see, one just needs to change some R code). However, I haven't done extensive testing and I'm not an expert on shared projects and subversion (never did that actually), so I guess I would need some help to start with and the confirmation I couldn't break anything ;-)</div>
<div><br></div><div>Christoph</div><div><br></div><br>
</div>