Skip to content
Back to formatted view

Raw Message

Message-ID: <45f568c70902110643w60452196h2fa29381bc0b2327@mail.gmail.com>
Date: 2009-02-11T14:43:28Z
From: Gustaf Rydevik
Subject: Beginner-how to down size a large sample
In-Reply-To: <3c89a8900902110615u487817yf131dbe002dfc1a9@mail.gmail.com>

On Wed, Feb 11, 2009 at 3:15 PM, pramil cheriyath <drpramil at gmail.com> wrote:
> I have this large data set with an outcome variable 0 and 1,  I want
> to randomly pick 100 from each group and create another data set.
>
> ______________________________________________
> 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.
>



dataSet<-data.frame(group=sample(c(1,0),10000,replace=T),data=rnorm(10000))
dataSet.1<-dataSet[dataSet$group==1,]
dataSet.0<-dataSet[dataSet$group==0,]
sampled.1<-dataSet.1[sample(1:nrow(dataSet.1),100),]
sampled.0<-dataSet.0[sample(1:nrow(dataSet.0),100),]

newdataSet<-rbind(sampled.1,sampled.0)

/Gustaf
(a "please", would have been nice....)

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik