[R] lost in vegan package

eva epitta at upatras.gr
Tue Aug 31 10:41:06 CEST 2010




Jari Oksanen wrote:
> 
> eva <epitta <at> upatras.gr> writes:
> 
>> 
>> 
>> Hi R Helpers, 
>> I'm still new to R and i experience many difficulties..I'm using vegan
>> package (R version 2.11) trying to calculate checkerboard units for each
>> species pair of a matrix. I've prepared the function:
>> 
>> pair.checker=function (dataset) {designdist (dataset,
>> method="c("(A-J)x(B-J)", terms ="binary", abcd=FALSE)}
>> 
>> to use with function oecosimu as follows:
>> 
>> oecosimu(dataset, pair.checker, "tswap", nsimul=5000, burnin=0,
>> thin=thin,
>> statistic="pair.checker")
>> 
>> It seemed to work but the output did not include each species pair name.
>> I
>> don't know what to do. First column was all NAs. I copied and pasted the
>> results of the console and named each species pair in Excel by hand. But
>> then I got this really big matrix with 3828 possible species pairs. The
>> console couldn't show all posssible species pairs even after resetting
>> the
>> max.print option. I've tried saving the output as:
>> 
> Eva,
> 
> You have several problems with your example:
> 
> 1) there is a syntax error (or several syntax errors) in the designdist()
> 'method' you have in you pair.checker().
> 2) designdist() finds dissimilarities between rows, and with standard
> usage 
> yourspecies are columns: you must transpose your data.
> 3) designdist() returns a "dist" object which does not have names of pairs 
> of species, but you must make them.
> 4) you should not give the name of the 'statistic' in the oecosimu unless 
> you return the result in a list with an item named by the value given to 
> the statistic.
> 
> Below is a version that seems to work. It corrects the syntax of 'method', 
> andchanges the result to a vector named by the species pairs, but it 
> doesn't transpose your data:
> 
> pair.checker <- function (dataset) 
> {
>   d <- designdist (dataset, method="(A-J)*(B-J)", terms ="binary")
>   nm <- outer(labels(d), labels(d), paste)[lower.tri(d)]
>   d <- as.vector(d)
>   names(d) <- nm
>   d
> }
> 
> If your species are columns (like usually in vegan data set), you must 
> transposeyour data when calling this using t() function. Here is a 
> working oecosimu call:
> 
> oecosimu(t(dune), pair.checker, "tswap", nsimul = 5000, burnin = 0)
> 
> I didn't give 'thin' here, since you didn't have a numeric value for
> 'thin' 
> in your example. Further, you shall not give the name of the 'statistic' 
> since pair.checker() returns an unnamed vector.
> 
> So you write from Patras... I've carried home a paper by Giokas & 
> Sfenthourakis to see at my leisure how to implement their methodology in 
> vegan. I guess it's above...
> 
> Cheers, Jari Oksanen
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

Dr Oksanen,

Thank you very very much. I thought I wouldn't never find the right way of
calculating species pairs occurrences in vegan package.  
My data are already transposed. Do you know a way of saving the output? I
can only copy and paste the results in an Excel worksheet. For large numbers
of species pairs the console will not show all possible species pairs.

Thank's
Eva

PS: I'm a PhD student and my supervisor is Dr Sfenthourakis. We are
currelntly evaluating the performance of species pair metrics, such as joint
occurrences of species pairs on islands, in artificial and real matrices.

-- 
View this message in context: http://r.789695.n4.nabble.com/lost-in-vegan-package-tp2400145p2401227.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list