kdd.from.raw.data: Build a KDD object from raw data

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/KDD.R

Description

Build a KDD (Key Day Dataset) object from a matrix or a data frame containing a time series and other attributes.

Usage

1
2
kdd.from.raw.data(raw.data, keyday.threshold, nb.days, col.series, col.date, 
na.rm = TRUE, filter = NULL)

Arguments

raw.data

a data frame or a matrix containing raw data.

keyday.threshold

a numeric providing the threshold value above which a day is considered as a key day (i.e. if the value y_i of the times series is greater than or equal to keyday.threshold at day i, then day i is a key day).

nb.days

an integer specifying the number of days considered after and before each key day.

col.series

an integer specifying the number of the column containing the time series.

col.date

an integer vector of size three specifying the numbers of the columns containing the vector of years, the vector of months and the vector of days in numeric format.

na.rm

a logical indicating whether key days i with missing values in the sub-series y_{i-K},…,y_{i+K} have to be discarded. If na.rm = TRUE, these key days are discarded (default is TRUE).

filter

a list of lists specifying the filters to carry out over the time series (default is NULL).

Details

The filter argument is a list of lists, each list having the following arguments:

apply.over:

a character string that must be one of "keyday" or "range", and that indicates whether the filter concerns only the key days or also the range of days considered around the key days (K days before and K days after each key day).

column:

an integer specifying the column of raw.data which the filter is applied to.

value:

a value that must be taken by the variable determined by the argument column.

Let i denote a key day. Let z_i denote the value, at day i, of the variable determined by the argument column. If apply.over = "keyday" and z_i = value, then key day i is kept, otherwise it is discarded. If apply.over = "range" and z_j = value for all j\in\{i-K,…,i+K\}, then key day i is kept, otherwise it is discarded.

Value

an object from the KDD class.

Author(s)

Samuel Soubeyrand Samuel.Soubeyrand@avignon.inra.fr, Cindy E. Morris, E. Keith Bigg.

References

Soubeyrand, S., Morris, C. E. and Bigg, E. K. (2014). Analysis of fragmented time directionality in time series to elucidate feedbacks in climate data. Environmental Modelling and Software 61: 78-86.

See Also

KDD, kdd, rain.site.6008

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#### load data for site 6008 (Callagiddy station)
data(rain.site.6008)

#### build KDD objects from raw data (site 6008: Callagiddy station)
## using a threshold value equal to 25
KDD=kdd.from.raw.data(raw.data=rain.site.6008,keyday.threshold=25,nb.days=20,
   col.series=5,col.date=c(2,3,4),na.rm=TRUE,filter=NULL)
summary(KDD)

#### build KDD objects from raw data (site 6008: Callagiddy station)
## using a threshold value equal to 25
## using filters
rain.site.6008b=cbind(rain.site.6008,rain.site.6008[["Year"]]>=1960)
KDD2=kdd.from.raw.data(raw.data=rain.site.6008b,keyday.threshold=25,nb.days=20,
   col.series=5,col.date=c(2,3,4),na.rm=TRUE,
   filter=list(list(apply.over="range",column=6,value=TRUE)))
summary(KDD2)

Example output

Loading required package: maps
Loading required package: mapdata
Loading required package: proj4
Loading required package: sp
Loading required package: geoR
--------------------------------------------------------------
 Analysis of Geostatistical Data
 For an Introduction to geoR go to http://www.leg.ufpr.br/geoR
 geoR version 1.7-5.2.1 (built on 2016-05-02) is now loaded
--------------------------------------------------------------

Warning message:
no DISPLAY variable so Tk is not available 
Keyday data object:
Data period:  1910 - 2009 
Keyday threshold:  25 
Total number of keydays:  204 
Mean and standard deviation of rainfalls at keydays:  40.7  and  16.33 
Keyday data object:
Data period:  1960 - 2009 
Keyday threshold:  25 
Total number of keydays:  107 
Mean and standard deviation of rainfalls at keydays:  39.61  and  15.33 

FeedbackTS documentation built on Jan. 23, 2020, 5:06 p.m.