[R] sample
Wu Gong
ghowoo at gmail.com
Mon May 17 05:18:40 CEST 2010
I tried cbind, it works.
moms<-read.delim("females.txt", sep =" ",stringsAsFactors=FALSE,header=TRUE)
dads<-read.delim("males.txt", sep =" ",stringsAsFactors=FALSE,header=TRUE)
output_offspring <-
cbind(moms[,c(1,sample((2:5),2))],dads[sample(nrow(dads),nrow(moms),replace=TRUE),c(1,sample((2:5),2))])
write.table(output_offspring,"offspring_7.txt",row.names=F,col.names=c("momID","A1","A2","dadID","A3","A4"),quote=F)
I hope someone can give a solution with matrix operation.
And, it seems that there are 4 repeated IDs in females.
-----
A R learner.
--
View this message in context: http://r.789695.n4.nabble.com/sample-tp2218361p2219047.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list