[R-sig-eco] Time Series Analyses of Environmental Water Chemistry

Seibert, Simon (IWG) simon.seibert at kit.edu
Fri Sep 28 11:27:42 CEST 2012


Dear Rich,
In principle zoo() is able to create objects with duplicate index vectors. Nevertheless it’s recommended to use a unique order.by argument since some R functionalities may not work as they are supposed to do if redundant indices are provided… (see Details section in ?zoo). 
However, I don’t understand why you even have duplicate indices within individual the data frames, if your chemicals are all stored in separated ones? Maybe check for redundancies within the individual data frames using the unique() function. 
To create a homogeneous record set I recommend the following steps: 1. figure out the earliest available timestamp and the latest one considering all your individual measurements. 2. Create an equally spaced sequence (by hours, days, whatever,…) in between them using seq() 3. Now you can easily combine the sequence and (all) individual measurements using merge() in a single equidistant zoo object (watch out that your timestamps are all converted to the POSIX format).

one example: I’m handling streamflow data from various different sites (these could also be chemicals) covering various different periods in a single zoo object. provided a data frame which may look like this: 	   
	   dts   tms INGP KELH KELW OBND
07.03.2002 02:00  412  448  477   NA
07.03.2002 03:00  415  444  455   NA
07.03.2002 04:00  415  439  437  482
07.03.2002 05:00  412  435   NA  466
07.03.2002 06:00  407  434   NA  457
you can easily convert it into a zoo obejct  using the following commands timedef <- as.POSIXct(strptime(apply(data[,1:2],1, paste, collapse=" "),"%d.%m.%Y %H:%M"), tz="UTC") zoodata <- zoo(data[,-1:-2], order.by= timedef) zoodata

cheers
Simon

 - - - - - - - - - - - - - - - - - - - - - - 
Simon Seibert M.Sc. Ing.-Oek.
Karlsruhe Institute of Technology (KIT)
Institute of Water and River Basin Management Section Hydrology Kaiserstrasse 12 • 76131 Karlsruhe • Germany

+49.721.608.43982 [fon] • +49.721.608.45651 [fax] • 420.4 [room] • 
+http://hyd.iwg.kit.edu/ [url]

KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association

| -----Ursprüngliche Nachricht-----
| Von: r-sig-ecology-bounces at r-project.org 
| [mailto:r-sig-ecology-bounces at r- project.org] Im Auftrag von Rich 
| Shepard
| Gesendet: Donnerstag, 27. September 2012 19:02
| An: r-sig-ecology at r-project.org
| Betreff: [R-sig-eco] Time Series Analyses of Environmental Water 
| Chemistry
| 
|    If this is not the appropriate mail list for my questions, please 
| point me to the proper list.
| 
|    Two projects require time series analyses of water chemistry. As is 
| common with permit compliance monitoring data the frequencies are not 
| regular; for example, sometimes the stream channel is dry, other times 
| it's covered by a few meters of snow and ice. Also, sampling locations 
| can be visited on different (usually adjacent) days, and quite often 
| (particularly with
| metals) concentrations are left-censored below the reporting levels.
| 
|    I have data for each chemical in a separate data frame. Applying 
| zoo() to this structure gives me a warning about multiple date 
| instances; for example,
| 
|   as.d.z <- zoo(x=as.d$quant, order.by=as.d$sampdate, frequency=NULL) 
| Warning message:
| In zoo(x = as.d$quant, order.by = as.d$sampdate, frequency = NULL) :
|    some methods for “zoo” objects do not work if the index entries in 
| ‘order.by’ are not unique
| 
|    For now I want to analyze the data regardless of site (in the above 
| example that would be for all dissolved arsenic). There may be a need 
| in the future to look at the time series for each site (I hope not!!) or a few specific sites.
| 
|    Since all this is a new area of R for me I seek advice on how to 
| apply R for time series analyses of these data.
| 
| Rich
| 
| _______________________________________________
| R-sig-ecology mailing list
| R-sig-ecology at r-project.org
| https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


More information about the R-sig-ecology mailing list