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 ______________________________________________ R-help@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.