How can I automate random row selection?<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hello All,
I'm pretty new to JMP and even newer to JSL. I'm trying to write a script that subsets a number of rows based on the following specifications: if the original table has 1-15 rows, then the subset of the original table is 2 rows, if the original has 16-25 then the subset of that table is 3 rows, if the orginal has 26-90 then the subset table is 5 rows, etc. Basically just a script to automate .
subset>random-sample size: [user inputs number] >ok based on a specified range of rows. So far I've tried the following:
New Script ("Random Row Check,
if (n row==1::15, current data table()<
if (n row==16::25, current data table()<
if (n row==26::90, current data table()<
if (n row==91::150, current data table()<
if (n row==151::280,current data table()<
if (n row==281::500, current data table()<
if (n row >=501, current data table()<
)
This script returns an empty data table. I know this must be something simple, but I can't seem to the forest for the the trees. Thanks for any help!
Re: How can I automate random row selection?Thanks so much! This is exactly what I needed
Re: How can I automate random row selection?You're almost there. Try this:
n = nrows(current data table());
if (n <= 15, current data table() << subset(sample size(2)),
n <= 25, current data table() << subset(sample size(3)),
n <= 90, current data table() << subset(sample size(5)),
n <= 150, current data table() << subset(sample size(6)),
n <= 280, current data table() << subset(sample size(7)),
n <= 500, current data table() << subset(sample size(9)),
n >= 501, current data table() << subset(sample size(15)),
)