JohnThanks!Hi Jaime,Sorry to bother you again about this, but any thoughts on the question below?On Sun, Aug 23, 2015 at 9:58 AM, John Williams <jnwil...@gmail.com> wrote:Jaime,
Jaime Ashander <jash...@ucdavis.edu>: Aug 19 05:47PM -0700
Jaime,
Thanks for your help with this, and sorry it's taken me until now to get back to you. Your suggestion looks like it will work. I have a question about how I deal with the fact that my sites have different number of plots (sorry, my sample data didn't include that detail). So, if I understand the code you wrote, where
plots.per.site <- 5
but I actually have plots at site A = 41 and plots at site B = 43.Also, and this probably goes hand-in-hand with the answer to the question above, can you just briefly explain how the 2 lines of code below that you wrote work?Thanks so much!John
d.mat[ 1:plots.per.site, 1:plots.per.site] <- within.site.value
d.mat[ (plots.per.site + 1):(2*plots.per.site), (plots.per.site + 1):(2 * plots.per.site)] <- within.site.value
John,
This might get you there. I think it's in the spirit of what Steve
suggested: do all the comparisons, make the within-site comparisons null,
then take the average ignoring the null values.
library(vegan)
read.csv("JW_Sample_Sorensen.csv") -> d
1 - vegdist(d[ ,-1], method="bray", binary=T, diag=T) -> d.dist
# within.site out within sites
plots.per.site <- 5
within.site.value <- NA
d.mat <- as.matrix(d.dist)
d.mat[ 1:plots.per.site, 1:plots.per.site] <- within.site.value
d.mat[ (plots.per.site + 1):(2*plots.per.site), (plots.per.site + 1):(2 *
plots.per.site)] <- within.site.value
#if you have > 2 sites need to put the above in a loop
# basic strategy is to make all NA within the block diagonal matrix of sites
d.site.dist <- as.dist(d.mat)
# this gives the mean across all comparisons between of plots between the
two
# sites. for > 2 sites geting site-site distances would be more complicated
mean(d.site.dist, na.rm=TRUE)
[1] 0.2855238
--
Check out our R resources at http://www.noamross.net/davis-r-users-group.html
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+...@googlegroups.com.
Visit this group at http://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.
[1] 0.193819