Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Eduard Szöcs
Hai Richard,


have a look at:

Borcard, Daniel, Francois Gillet, and Pierre Legendre. /Numerical 
Ecology with R (Use R)/. 1st Edition. Springer, 2011.

which is the little brother to Legendre's Numerical Ecology, applying 
these methods with R.


A very nice freely available book using R is:

Kindt, Roeland, and Richard Coe. /Tree Diversity Analysis: [a Manual and 
Software for Common Statistical Methods for Ecological and Biodiversity 
Studies]/. Nairobi and Kenya: World Agrofirestry Centre, 2005. 
Available here: 
http://www.worldagroforestry.org/downloads/publications/PDFs/MN08242.PDF


HTH,

Eduard




On 12/06/2012 02:26 AM, Rich Shepard wrote:
>   I left academia and basic ecological research decades ago and now work
> with environmental data collected by companies in compliance with 
> regulatory
> permit requirements. I've bought and read (mostly) all the books I could
> find on ecological analyses using R (all but one of Alain Zuur's books,
> Legendre & Legendre's 2nd English edition, Mike McCarthy's Bayesian 
> methods
> book, and Ben Bolker's book) but cannot find any references to 
> 'communities'
> in the indices. I'd greatly appreciate pointers to sources appropriate 
> for
> environmental data (which is much sloppier than ecological research 
> data).
>
>   The last time I addressed community analyses was my post-doc research
> which I published in Freshwater Biology in 1984. Only within the past 
> year
> have my clients needed to address issues using benthic macroinvertebrate
> assemblages (and fish) in streams. And, since I work by myself, I've 
> no one
> with whom to share ideas and discuss approaches; perhaps there's a better
> forum than this mail list for this.
>
>   The available benthic data has little taxonomic consistency below the
> family level. I want to use functional feeding groups rather than taxa as
> the basis of comparison because those better reflect conditions in each
> stream (collections of biota are made only once per year), and I want to
> examine correlations and cause-and-effect relations between biotic
> assemblages and water chemistry. There are only a few fish collections,
> tool, in the available data.
>
>   All ideas are certainly welcome!
>
> TIA,
>
> Rich
>


[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Rich Shepard

On Thu, 6 Dec 2012, alfredo tello wrote:


Check out the R package Vegan tutorial by Jari Oksanen:
http://cc.oulu.fi/~jarioksa/opetus/metodi/vegantutor.pdf. Vegan has
several functions which I believe should allow you to address some of your
questions.


Alfredo,

  I will certainly do this.


I have not worked with functional groups, but I'm guessing you could treat
them as you would treat taxa for statistical purposes(?)


  For benthic macroinvertebrates I'll strongly argue that functional feeding
groups are better than the mixed taxonomic levels that are usually given
equal weights. So yes, statistical models should work equally well,
particularly if the methods will work with percentages (proportions) which
normalize for different numbers of individuals in the different streams.


I think Vegan's function 'adonis' might be of interest to you. It allows
you to partition variation in a data/distance matrix according to
specified factors (e.g., water chemistry).

Hopet this helps!


  I'm sure it will.

Thanks very much,

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |
 Voice: 503-667-4517  Fax: 503-667-8863

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Rich Shepard

On Thu, 6 Dec 2012, Eduard Szöcs wrote:


have a look at:

Borcard, Daniel, Francois Gillet, and Pierre Legendre. /Numerical
Ecology with R (Use R)/. 1st Edition. Springer, 2011.

which is the little brother to Legendre's Numerical Ecology, applying
these methods with R.


Eduard,

  I have both; looked at the indices rather than the tables of contents.

Thanks,

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |
 Voice: 503-667-4517  Fax: 503-667-8863

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Rich Shepard

On Thu, 6 Dec 2012, Alan Haynes wrote:


Theres a book coming out next May by Otto Wildi called "Data Analysis in
Vegetation Ecology" 2nd Edition which includes a lot of R code. While its
aimed at vegetation ecology, a lot of the principles in the book can be
generalised to community analysis in whatever form. It covers ordination,
cluster analysis, some basic GLM and numerous other topics.


  Thanks, Alan. With care plant and terrestrial anaimal community measures
can be applied to aquatic organisme. I'll keep watch on this book.

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |
 Voice: 503-667-4517  Fax: 503-667-8863

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Ian R Waite
Rich,

I would suggest checking out the following book -- I find it very useful
and well written, using good case studies and all with R.

 Environmental and Ecological Statistics with R (Chapman & Hall/CRC Applied
 Environmental Statistics) [Paperback]
 Song S. Qian (Author)
 › Visit Amazon's Song S. Qian Page


Not to start  a debate, but I would suggest considering using
macroinvertebrate metrics such as EPT Richness or Ave. Tolerant Richness or
NonInsect Richness, etc. as your response measures instead of functional
feeding groups but this requires the user to come to a common taxonomic
resolution level -- for each major group make sure all samples have data
aligned at the same level if the taxa occur in those samples. Example, all
Ephemeroptera are ID'd to Genus or Family level for all samples, higher
level specimens are either removed or proportioned into their children.
(See Cuffney's paper on this subject -- attached below).

With the data resolved for taxonomic issues, you can then also use specie
matrix methods of similarity indices such as Bray-Curtis and others that
then allow you to try a variety of multivariate methods -- cluster
analysis, ordinations, ANOSIM, etc.

Just my two cents, HTH

Ian


(See attached file: Cuffney-2007_Ambiguous Taxa_JNABS.pdf)


~^^~~^^^~~~^^~~~~~~^~~^~~^~~^^~~~^^^~~~~~^~~^~~^~~
Ian R. Waite, Ph.D.
Aquatic Ecologist
USGS - OWSC
2130 SW 5th Avenue
Portland, OR 97201
email: iwa...@usgs.gov

   "Sometimes your joy is the source of your smile, but
 sometimes your smile can be the source of your
joy."
Thich Nhat Hanh
"We may search the world over for joy but
  unless we carry it within us, we will not find it."
Ralph Waldo Emerson
~^^^~~~^^^^^^~~^^^^^~~~^~^^^~~~~~^~~


|>
| From:  |
|>
  
>--|
  |Rich Shepard   
 |
  
>--|
|>
| To:|
|>
  
>--|
  |r-sig-ecology@r-project.org  
 |
  
>--|
|>
| Date:  |
|>
  
>--|
  |12/06/2012 06:12 AM  
 |
  
>--|
|>
| Subject:   |
|>
  
>--|
  |Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and 
Biota|
  
>--|
|>
| Sent by:   |
|>
  
>--|
  |r-sig-ecology-boun...@r-project.org  
 |
  
>--|





On Thu, 6 Dec 2012, alfredo tello wrote:

> Check out the R package Vegan tutorial by Jari Oksanen:
> http://cc.oulu.fi/~jarioksa/opetus/metodi/vegantutor.pdf. Vegan has
> several functions which I believe should allow you to address some of
your
> questions.

Alfredo,

   I will certainly do this.

> I have not worked with functional groups, but I'm guessing you could
treat
> them as you would treat taxa for statistical purposes(?)

   For benthic macroinvertebrates I'll strongly argue that functional
feeding
groups are better than the mixed taxonomic levels that are usually given
equal weights. So yes, statistical models should work eq

[R-sig-eco] error in layernames and RasterStack

2012-12-06 Thread Alok K. Bohara
Hi:  I am trying to replicate  some commands in maxlike. 


#***
library(raster)

set.seed(131)
x1 <- sort(rnorm(100))
x1 <- raster(outer(x1, x1), xmn=0, xmx=100, ymn=0, ymx=100)
x2 <- raster(matrix(runif(1e4), 100, 100), 0, 100, 0, 100)
x3 <- raster(matrix(c(0,1), 100, 100), 0, 100, 0, 100)
r <- stack(x1, x2, x3)
r@layernames <- c("x1", "x2", "x3")

#

Error #1:  After the last line, I get an Error:

Error in checkSlotAssignment(object, name, value) : 
  ‘layernames’ is not a slot in class “RasterStack”
> 



Error # 2:  Later, I also get an error:

In addition: Warning message:
> fm2 <- maxlike(~x1 + x2 + x3, r, xy)
Error in maxlike(~x1 + x2 + x3, r, xy) : 
  at least 1 covariate in the formula is not in rasters.

In layerNames(rasters) :
  the layerNames function is obsolete. Use "names" instead



I am using  R 2.15.2.  I do not know if the error #2 is the result of the error 
#1.Thanks.



Best,
Alok K. Bohara, 
UNM

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] error in layernames and RasterStack

2012-12-06 Thread Baldwin, Jim -FS
I think you might want

  names(r) <-  c("x1", "x2", "x3")

rather than

  r@layernames <- c("x1", "x2", "x3")

Jim


-Original Message-
From: r-sig-ecology-boun...@r-project.org 
[mailto:r-sig-ecology-boun...@r-project.org] On Behalf Of Alok K. Bohara
Sent: Thursday, December 06, 2012 10:26 AM
To: r-sig-ecology@r-project.org
Subject: [R-sig-eco] error in layernames and RasterStack

Hi:  I am trying to replicate  some commands in maxlike.


#***
library(raster)

set.seed(131)
x1 <- sort(rnorm(100))
x1 <- raster(outer(x1, x1), xmn=0, xmx=100, ymn=0, ymx=100)
x2 <- raster(matrix(runif(1e4), 100, 100), 0, 100, 0, 100)
x3 <- raster(matrix(c(0,1), 100, 100), 0, 100, 0, 100) r <- stack(x1, x2, x3) 
r@layernames <- c("x1", "x2", "x3")

#

Error #1:  After the last line, I get an Error:

Error in checkSlotAssignment(object, name, value) :
  'layernames' is not a slot in class "RasterStack"
>



Error # 2:  Later, I also get an error:

In addition: Warning message:
> fm2 <- maxlike(~x1 + x2 + x3, r, xy)
Error in maxlike(~x1 + x2 + x3, r, xy) :
  at least 1 covariate in the formula is not in rasters.

In layerNames(rasters) :
  the layerNames function is obsolete. Use "names" instead



I am using  R 2.15.2.  I do not know if the error #2 is the result of the error 
#1.Thanks.



Best,
Alok K. Bohara,
UNM

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology





This electronic message contains information generated by the USDA solely for 
the intended recipients. Any unauthorized interception of this message or the 
use or disclosure of the information it contains may violate the law and 
subject the violator to civil or criminal penalties. If you believe you have 
received this message in error, please notify the sender and delete the email 
immediately.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota [RESOLVED]

2012-12-06 Thread Rich Shepard

On Wed, 5 Dec 2012, Rich Shepard wrote:


 The available benthic data has little taxonomic consistency below the
family level.


  Looking at packages in CRAN brought me to Lester Yuan's bio.infer package
described in the 2007 Journal of Statistical Software special issue on
ecology/environmental data analyses. It is ideal for my needs and I will
contact Lester with the questions I have (such as updating the ITIS database
it uses).

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |
 Voice: 503-667-4517  Fax: 503-667-8863

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Philippi, Tom
While vegan and other packages offer many powerful tools for analyzing
species composition data, there's a fair bit available that is more
directly aimed at using aquatic biotic data for water quality monitoring
and assessment.  I suggest spending some time with r-seek (www.rseek.org)
to find out what's available, as quite a few water quality & monitoring
folks use R, and many of the US Government folks make their code available
as downloads or sometimes packages.

EPA has quite a bit of relevant R code available: spsurvey for GRTS sample
draws & analyses is on CRAN, but they also have code for RIVPACS and other
approaches available on their websites:
http://www.epa.gov/wed/pages/models/rivpacs/rivpacs.htm
(it appears that the port-to-a-new-content-system bug bit EPA, so you may
have to search their site for the download).

You might find what you need in package bio.infer: it has functions for
cleaning taxonomic names, pooling within-site duplicates, mapping taxa to
feeding groups based on Vieira et al., and calibrating and computing some
indices.

Package analogue does weighted averaging and similarity and other
approaches for inferring environmental conditions from taxonomic
composition (e.g., paleohydrology from diatoms).

There's also a package for Functional Diversity:
https://r-forge.r-project.org/projects/fdiversity/

I am not expressing my opinion on the appropriateness of any of these
approaches to monitoring of biotic responses to water quality and habitat
conditions.

Tom 2



---
Tom Philippi, Ph.D.
Quantitative Ecologist & Data Therapist
Inventory and Monitoring Program
National Park Service
(619) 523-4576
tom_phili...@nps.gov
http://science.nature.nps.gov/im/monitor
library(fortunes)
fortune(206)

[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota [RESOLVED]

2012-12-06 Thread EJ BURTON
Hi Rich

You could have a look at 'Simulation of Ecological and Environmental Models' by 
Miguel F. Acevedo - CRC Press - Frances & Taylor Group.


Whether it would be useful I don't know as it is way, way above my level of 
understanding. It uses R.

Regards

Jim Burton




 From: Rich Shepard 
To: r-sig-ecology@r-project.org 
Sent: Thursday, 6 December 2012, 18:29
Subject: Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry 
and Biota [RESOLVED]

On Wed, 5 Dec 2012, Rich Shepard wrote:

>  The available benthic data has little taxonomic consistency below the
> family level.

  Looking at packages in CRAN brought me to Lester Yuan's bio.infer package
described in the 2007 Journal of Statistical Software special issue on
ecology/environmental data analyses. It is ideal for my needs and I will
contact Lester with the questions I have (such as updating the ITIS database
it uses).

Rich

-- Richard B. Shepard, Ph.D.          |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |
     Voice: 503-667-4517      Fax: 503-667-8863

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Applied Environmental Data Analyses: Water Chemistry and Biota

2012-12-06 Thread Rich Shepard

On Thu, 6 Dec 2012, Ian R Waite wrote:


Just my two cents, HTH


Ian,

  Thank you.

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |
 Voice: 503-667-4517  Fax: 503-667-8863

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[R-sig-eco] difftime in R

2012-12-06 Thread Kristen Gorman
Dear all, 
I am trying to calculate the difference between 2 times, each expressed as a 
Date and associated Time, see the below test example:

EventT1T2
112-06-01 1:00 12-06-02 0:00
212-06-01 1:00 12-06-02 0:00
312-06-01 1:00 12-06-02 0:00
412-06-01 1:00 12-06-02 0:00
512-06-01 1:00 12-06-02 0:00

when I run the difftime fxn I get the appropriate hours:

T1<- as.POSIXlt(DataSetb$T1)
T2<- as.POSIXlt(DataSetb$T2)

T3<- difftime(T2,T1)
T3

Time differences in hours
 [1] 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23

But then when I write this to the dataframe, it looks like:

DataSetb.2<- cbind(DataSetb,T3)

write.table(DataSetb.2, file="DataSetb.2.csv", col.names=NA, sep=",")


EventT1T2   T3
112-06-01 1:00 12-06-02 0:00 23 hours
212-06-01 1:00 12-06-02 0:00 23 hours
312-06-01 1:00 12-06-02 0:00 23 hours
412-06-01 1:00 12-06-02 0:00 23 hours
512-06-01 1:00 12-06-02 0:00 23 hours

I would like the T3 column to just have the values (23) and not (23 hours). 
Does anyone know how to remove the hours from being written to the dataframe? 
Maybe there is a better way to do this than using difftime?

Thanks in advance for your help.

Kristen

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] difftime in R

2012-12-06 Thread Thomas Petzoldt

try:

as.numeric(T3)

Note that this is a typical "r-help" question.

Thomas Petzoldt

--
DataSetb <- data.frame(
  T1 = rep("2012-06-01 1:00", 5),
  T2 = rep("2012-06-02 0:00", 5)
)


T1<- as.POSIXlt(DataSetb$T1)
T2<- as.POSIXlt(DataSetb$T2)

T3<- as.numeric(difftime(T2, T1))
T3


DataSetb.2<- cbind(DataSetb,T3)
write.table(DataSetb.2, file="DataSetb.2.csv", col.names=NA, sep=",")

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] difftime in R

2012-12-06 Thread Daniel Pritchard
Hi Kristen,

Thomas is right on both counts.  Though, as a further word of caution, it is 
not guaranteed that difftime() will return data in 'hours'.  This is probably 
the reason why it returns a special class whose format() method tries so very 
hard to include the units.  

I'd suggest either specifying your intended units in the call to difftime() 
and/or storing the unit information alongside T3.

~~~
T3<- difftime(T2,T1, units='hours')
## and/or
DataSetb.2<- cbind(DataSetb,'T3'=as.numeric(T3), 'T3_units' = rep(units(T3), 
length(T3)))
~~~

Daniel Pritchard

On 7 Dec 2012, at 16:52, Thomas Petzoldt  wrote:

> try:
> 
> as.numeric(T3)
> 
> Note that this is a typical "r-help" question.
> 
> Thomas Petzoldt
> 
> --
> DataSetb <- data.frame(
>   T1 = rep("2012-06-01 1:00", 5),
>   T2 = rep("2012-06-02 0:00", 5)
> )
> 
> 
> T1<- as.POSIXlt(DataSetb$T1)
> T2<- as.POSIXlt(DataSetb$T2)
> 
> T3<- as.numeric(difftime(T2, T1))
> T3
> 
> 
> DataSetb.2<- cbind(DataSetb,T3)
> write.table(DataSetb.2, file="DataSetb.2.csv", col.names=NA, sep=",")
> 
> ___
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Daniel Pritchard
Research Fellow
Marine Research Group
School of Planning, Architecture and Civil Engineering (SPACE)
Queens University Belfast

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology