Dear all,
Per Jensen, thanks for your great help. All methods are very useful.
Best, Muhammad Subianto
On this day 20/06/2006 22:28, Per Jensen wrote:
A couple of suggestions:
#First solution
mydatexpanded-mydat[rep(1:5,mydat[,1]),]
sampledat-mydatexpanded[sample(1:85,7),-1]
#Second
Dear all R-users,
(My apologies if this subject is wrong)
I have dataset:
mydat - as.data.frame(
matrix(c(14,0,1,0,1,1,
25,1,1,0,1,1,
5,0,0,1,1,0,
31,1,1,1,1,1,
10,0,0,0,0,1),
nrow=5,ncol=6,byrow=TRUE))
A couple of suggestions:
#First solution
mydatexpanded-mydat[rep(1:5,mydat[,1]),]
sampledat-mydatexpanded[sample(1:85,7),-1]
#Second solution
sampledat-mydat[sample(1:5,size=7,prob=mydat[,1]/85,replace=TRUE),-1]
Regards
Per Jensen
On 6/20/06, Muhammad Subianto [EMAIL PROTECTED] wrote:
Dear