[R] : how to select rows at random

Laura Rodriguez Murillo laura.lmurillo at gmail.com
Fri Mar 27 20:40:00 CET 2009


Thank you so much again!

Laura

2009/3/27 jim holtman <jholtman at gmail.com>:
> I meant type in "?sample" to see what the 'sample' function does.  For
> example, to select 50 random rows,
>
>> sample(2000,50)
>  [1] 1004  857 1219 1850  480  543 1466 1498 1854  922 1713  621  414
> 1830  105  817  906  825 1329 1500 1806 1623  186  352 1270 1727 1170
> 518 1743  370  964   20  710  870  248 1227  594  471  704 1751
> [41] 1942 1435 1944 1057  849 1886  290  130   48 1195
>>
>
>
> On Fri, Mar 27, 2009 at 3:18 PM, Laura Rodriguez Murillo
> <laura.lmurillo at gmail.com> wrote:
>> Sorry, I'm attaching part of the file I have. They go up to 2000 and I
>> would like to take a subset of around 300.
>>
>>
>> 5001 1
>> 5001 2
>> 5001 3
>> 5001 5
>> 5001 6
>> 5002 1
>> 5002 2
>> 5002 5
>> 5002 6
>> 5002 11
>> 5002 15
>> 5002 16
>> 5003 1
>> 5003 2
>> 5003 5
>> 5003 6
>> 5004 1
>> 5004 2
>> 5004 5
>> 5004 6
>> 5004 10
>> 5004 11
>> 5004 12
>> 5004 15
>> 5004 16
>> 5004 25
>> 5004 26
>> 5004 35
>> 5004 36
>> 5004 45
>> 5004 46
>> 5004 55
>>
>>
>> Thank you!
>>
>> Laura
>>
>> 2009/3/27 jim holtman <jholtman at gmail.com>:
>>> ?sample
>>>
>>> On Fri, Mar 27, 2009 at 3:11 PM, Laura Rodriguez Murillo
>>> <laura.lmurillo at gmail.com> wrote:
>>>> Hi dear list,
>>>>
>>>> I have a list of around 2000 identifiers aranged in a dataframe in one
>>>> column and I would like to choose a random subset of these. I wonder
>>>> if somebody can tell me if I could do this with R...
>>>>
>>>> Thank you so much!
>>>>
>>>> Laura RM
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>>>
>>> --
>>> Jim Holtman
>>> Cincinnati, OH
>>> +1 513 646 9390
>>>
>>> What is the problem that you are trying to solve?
>>>
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>




More information about the R-help mailing list