Message-ID: <49C8DFDD.2030306@statistik.tu-dortmund.de>
Date: 2009-03-24T13:27:57Z
From: Uwe Ligges
Subject: Random sampling based on the observations
In-Reply-To: <22673975.post@talk.nabble.com>
Arup wrote:
> Hello!I am having a problem with Random sampling in R. I have used a syntax:
> mydata.sub=sample(mydata,7,replace=FALSE,prob=NULL) which allows me to
> choose a random sample based on the variables(correct me if I am wrong!).
> Suppose I have 10 variable and if I use the above mentioned command then it
> will choose 7 variables out of the 10 randomly. My problem is that I want to
> have a random sample which is not based on the variables but on the values
> of the variables that is the random sample will be based on the
> observations. It will be great if someone can help me out me out with a
> proper syntax. Thanks in Advance.
mydata[sample(nrow(mydata), 7),]
Uwe Ligges