R/sample.textmatrix.R

### -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  
### sample.textmatrix.R
### -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  
### created 2006-07-31

sample.textmatrix <- function (textmatrix, samplesize, index.return=FALSE) {

	if (!inherits(textmatrix, "textmatrix")) {
		stop("[sample.textmatrix] ERROR: first argument not a textmatrix."); 
	}

	filelist = colnames(textmatrix)
	rnd_sample = sample(1:length(filelist), samplesize)
	if (index.return) {
		return(list(x=filelist[rnd_sample],ix=rnd_sample))
	} else {
		return(filelist[rnd_sample])
	}
	
} # sample.textmatrix()

Try the lsa package in your browser

Any scripts or data that you put into this service are public.

lsa documentation built on May 9, 2022, 9:10 a.m.