PageRenderTime 24ms CodeModel.GetById 22ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/packages/archive/2010/04.2010/04.24.2010/spacodi/R/r.sp_plot.R

http://github.com/eastman/spacodiR
R | 19 lines | 18 code | 1 blank | 0 comment | 1 complexity | 005a73804753de6b15e9357c2355c3f8 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