PageRenderTime 20ms CodeModel.GetById 18ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/archive/2010/04.2010/04.29.2010/spacodi/R/r.sp.plot.R

http://github.com/eastman/spacodiR
R | 19 lines | 18 code | 1 blank | 0 comment | 1 complexity | f890510bd58c67149cb989268ca8ca2e MD5 | raw file
 1r.sp.plot <-
 2function(obj,n.rep=10){
 3	sp.plot=obj
 4	zz=unlist(unname(obj))
 5	nulls=length(which(zz==0))
 6	l.data=length(zz)
 7	non.nulls=l.data-nulls
 8	yy=zz[which(zz!=0)]
 9	m.log=mean(log(yy))
10	out <- list() ### prep an output file
11	for(j in 1:n.rep){
12		foo <- as.data.frame(matrix(sample(c(round(rlnorm(n=non.nulls, meanlog=m.log)),rep(0,nulls))),nrow(sp.plot),ncol(sp.plot)))
13		rownames(foo) <- row.names(sp.plot)
14		names(foo)=names(sp.plot)
15		out[[j]]=foo
16	}
17	return(out)
18}
19