Hi Ethan,

I should clarify that you do not *need* to make size an integer, so
you technically do not need trunc(), but if you use trunc() or
round(), you get to be in control of what you get.  To answer your
second question, look at this little function, it even lets you choose
different percentages.  Notice how using -random.rows, one is able to
select all BUT those rows.

Cheers,

Josh


#Data for the example
x <- matrix(1:40, ncol = 2)

my.sampler <- function(name, percentage = 10){
  random.rows <- sample(nrow(name), trunc(nrow(x)*(percentage/100)))
  x.1 <- name[random.rows, ]
  x.2 <- name[-random.rows, ]
  value <- list(x.random = x.1, x.allelse = x.2)
  return(value)
}
#So you can see
my.sampler(x)

output <- my.sampler(x)

output$x.random
output$x.allelse



On Thu, Jul 22, 2010 at 4:59 PM, Xebar Saram <[email protected]> wrote:
> Wow guys
>
> thank you so much for the quick answers, i really appriciate it :)
>
> I have another question then if you dont mind. how does one proceed to
> randmomly split a single dataset into 90% and 10%?
>
> thx alot again
>
> Ethan
>
> On Thu, Jul 22, 2010 at 7:28 PM, Joshua Wiley <[email protected]> wrote:
>> On Thu, Jul 22, 2010 at 4:11 PM, jd6688 <[email protected]> wrote:
>>>
>>> Hi Joshua:
>>>
>>> how to do a permutation test on the following sample with the sample size in
>>> 20000 :
>>
>> Take a look at some of the results from
>>
>> RSiteSearch("permutation test")
>>
>> the "coin" package also comes to mind
>>
>> Josh
>>
>>
>>>
>>> id        weight      P VALUE
>>>
>>> 100      100
>>> 101       200
>>> 102       200
>>> 103       150
>>>
>>>
>>> .......
>>>
>>> Thanks
>>> --
>>> View this message in context: 
>>> http://r.789695.n4.nabble.com/choosing-a-random-sample-by-precentage-tp2299509p2299529.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> ______________________________________________
>>> [email protected] 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.
>>>
>>
>>
>>
>> --
>> Joshua Wiley
>> Ph.D. Student, Health Psychology
>> University of California, Los Angeles
>> http://www.joshuawiley.com/
>>
>> ______________________________________________
>> [email protected] 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.
>>
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
[email protected] 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.

Reply via email to