[R] Subsampling out of site*abundance matrix

B77S bps0002 at auburn.edu
Sun Feb 6 21:25:05 CET 2011


Hello, 
How can I randomly sample individuals within a sites from a site (row) X
species abundance (column) data frame or matrix?  As an example, the matrix
"abund2" made below.

##### (sorry, Im a newbie and this is the only way I know to get an example
on here)

abund1 <-    c(150,  300,  0,  360,  150,  300,  0,  240,  150,   0,  60,  
0, 150,  0, 540, 0, 0, 300, 0, 240, 300, 300, 0, 360, 300, 0, 600, 0)
abund2 <- matrix(data=abund1, nrow=4, ncol=7)
colnames(abund2) <- c("spA", "spB", "spC", "spD", "spa", "spF", "spG")
rownames(abund2)<-c("site1", "site2", "site3", "site4") 

#####

> abund2
      spA spB spC spD spa spF spG
site1 150 150 150 150   0 300 300
site2 300 300   0   0 300 300   0
site3   0   0  60 540   0   0 600
site4 360 240   0   0 240 360   0

How can I make a random subsample of 100 individuals from the abundances
given for each site?

This is probably really easy.
Thanks.
Bubba 
-- 
View this message in context: http://r.789695.n4.nabble.com/Subsampling-out-of-site-abundance-matrix-tp3263148p3263148.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list