Also, I really appreciate you explaining why you used factor. I'm still not quite sure what set.seed does (i read ?set.seed) or why you chose 123... but it and the function below work, so that is all that matters. :)
randSub <- function(L1, s.size) { set.seed(123) samptbl <- apply(L1, 1, function(x) sample(colnames(L1), s.size, prob=x, replace=TRUE) ) sampdf <- as.data.frame(samptbl) sampdf1 <-vector("list") for(i in 1:nrow(L1)) { sampdf1[[i]] <- factor(sampdf[[i]], levels= colnames(L1)) } out <- t(sapply(sampdf1, table)) } -- View this message in context: http://r.789695.n4.nabble.com/Subsampling-out-of-site-abundance-matrix-tp3263148p3264251.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.