dwi: Days with Information

Description Usage Arguments Author(s) See Also Examples

View source: R/dwi.R

Description

This function generates a table indicating the number of days with information (<>NA) within a zoo object, aggregated by year, month or month per year.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
dwi(x, ...)

## Default S3 method:
dwi(x, out.unit = "years", from = start(x), to = end(x), 
     date.fmt = "%Y-%m-%d", tstep="days", ...)
     
## S3 method for class 'zoo'
dwi(x, out.unit = "years", from = start(x), to = end(x), 
     date.fmt = "%Y-%m-%d", tstep="days", ...)

## S3 method for class 'data.frame'
dwi(x, out.unit = "years", from, to, date.fmt = "%Y-%m-%d", tstep="days", 
     dates = 1, verbose = TRUE, ...)
     
## S3 method for class 'matrix'
dwi(x, out.unit = "years", from, to, date.fmt = "%Y-%m-%d", tstep="days", 
     dates = 1, verbose = TRUE, ...)

Arguments

x

zoo, data.frame or matrix object, with daily/monthly/annual time series.
Measurements at several gauging stations can be stored in a data.frame of matrix object, and in that case, each column of x represent the time series measured in each gauging station, and the column names of x have to correspond to the ID of each station (starting by a letter).

out.unit

aggregation time for the computation of the amount of days with information. Valid values are:
-) months: monthly;
-) years : annual;
-) mpy : month per year (not available for data.frames)

from

Character indicating the starting date for the computations. It has to be in the format indicated by date.fmt.
When x is a data.frame and this value is not provided, the date corresponding to the first row of x is used

to

Character indicating the ending date for the computations. It has to be in the format indicated by date.fmt.
When x is a data.frame and this value is not provided, the date corresponding to the last row of x is used

date.fmt

character indicating the format in which the dates are stored in dates, e.g. %Y-%m-%d. See format in as.Date.
ONLY required when class(dates)=="factor" or class(dates)=="numeric".

tstep

Time step used for storing the values in x. Valid values are: days, months, years. Since the version 0.3-0 of hydroTSM, this argument is not required any more, because it is not used any longer.

dates

numeric, factor or Date object indicating how to obtain the dates for each column of x
If dates is a number, it indicates the index of the column in x that stores the dates
If dates is a factor, it is converted into Date class, using the date format specified by date.fmt
If dates is already of Date class, the code verifies that the number of days in dates be equal to the number of element in x

verbose

logical; if TRUE, progress messages are printed

...

further arguments passed to or from other methods.

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See Also

matrixplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Loading the SanMartino precipitation data
data(SanMartinoPPts)
x <- SanMartinoPPts

## Not run: 
## Days with information per year
dwi(x)

## Days with information per month per year.
dwi(x, out.unit="mpy")

## End(Not run)

###########
## Not run: 
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

## Months with information per year in the 9 first stations of 'EbroPPtsMonthly'
a <- dwi(EbroPPtsMonthly[,1:10], out.unit="years", dates=1)

## Before plotting the results in 'a', and just for obtaining a more interesting
## plot, 70 random numbers (between 1 and 11) are introduced in 'a'
a[sample(length(a), size = 70)] <- rep(1:11, length=70)

## Plotting the amount of months with information per year in each station
matrixplot(a, var.type="Days", main="Number of months with info per year")

## End(Not run)

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: xts
1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 
 365  365  365  366  365  365  365  366  365  365  365  366  365  365  365  366 
1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 
 365  365  365  366  365  365  365  366  365  365  365  366  365  365  365  366 
1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 
 365  365  365  366  365  365  365  366  365  365  365  366  365  365  365  366 
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 
 365  365  365  366  365  365  365  366  365  365  365  366  365  365  365  366 
1985 1986 1987 1988 1989 1990 
 365  365  365  366  365  365 
     Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1921  31  28  31  30  31  30  31  31  30  31  30  31
1922  31  28  31  30  31  30  31  31  30  31  30  31
1923  31  28  31  30  31  30  31  31  30  31  30  31
1924  31  29  31  30  31  30  31  31  30  31  30  31
1925  31  28  31  30  31  30  31  31  30  31  30  31
1926  31  28  31  30  31  30  31  31  30  31  30  31
1927  31  28  31  30  31  30  31  31  30  31  30  31
1928  31  29  31  30  31  30  31  31  30  31  30  31
1929  31  28  31  30  31  30  31  31  30  31  30  31
1930  31  28  31  30  31  30  31  31  30  31  30  31
1931  31  28  31  30  31  30  31  31  30  31  30  31
1932  31  29  31  30  31  30  31  31  30  31  30  31
1933  31  28  31  30  31  30  31  31  30  31  30  31
1934  31  28  31  30  31  30  31  31  30  31  30  31
1935  31  28  31  30  31  30  31  31  30  31  30  31
1936  31  29  31  30  31  30  31  31  30  31  30  31
1937  31  28  31  30  31  30  31  31  30  31  30  31
1938  31  28  31  30  31  30  31  31  30  31  30  31
1939  31  28  31  30  31  30  31  31  30  31  30  31
1940  31  29  31  30  31  30  31  31  30  31  30  31
1941  31  28  31  30  31  30  31  31  30  31  30  31
1942  31  28  31  30  31  30  31  31  30  31  30  31
1943  31  28  31  30  31  30  31  31  30  31  30  31
1944  31  29  31  30  31  30  31  31  30  31  30  31
1945  31  28  31  30  31  30  31  31  30  31  30  31
1946  31  28  31  30  31  30  31  31  30  31  30  31
1947  31  28  31  30  31  30  31  31  30  31  30  31
1948  31  29  31  30  31  30  31  31  30  31  30  31
1949  31  28  31  30  31  30  31  31  30  31  30  31
1950  31  28  31  30  31  30  31  31  30  31  30  31
1951  31  28  31  30  31  30  31  31  30  31  30  31
1952  31  29  31  30  31  30  31  31  30  31  30  31
1953  31  28  31  30  31  30  31  31  30  31  30  31
1954  31  28  31  30  31  30  31  31  30  31  30  31
1955  31  28  31  30  31  30  31  31  30  31  30  31
1956  31  29  31  30  31  30  31  31  30  31  30  31
1957  31  28  31  30  31  30  31  31  30  31  30  31
1958  31  28  31  30  31  30  31  31  30  31  30  31
1959  31  28  31  30  31  30  31  31  30  31  30  31
1960  31  29  31  30  31  30  31  31  30  31  30  31
1961  31  28  31  30  31  30  31  31  30  31  30  31
1962  31  28  31  30  31  30  31  31  30  31  30  31
1963  31  28  31  30  31  30  31  31  30  31  30  31
1964  31  29  31  30  31  30  31  31  30  31  30  31
1965  31  28  31  30  31  30  31  31  30  31  30  31
1966  31  28  31  30  31  30  31  31  30  31  30  31
1967  31  28  31  30  31  30  31  31  30  31  30  31
1968  31  29  31  30  31  30  31  31  30  31  30  31
1969  31  28  31  30  31  30  31  31  30  31  30  31
1970  31  28  31  30  31  30  31  31  30  31  30  31
1971  31  28  31  30  31  30  31  31  30  31  30  31
1972  31  29  31  30  31  30  31  31  30  31  30  31
1973  31  28  31  30  31  30  31  31  30  31  30  31
1974  31  28  31  30  31  30  31  31  30  31  30  31
1975  31  28  31  30  31  30  31  31  30  31  30  31
1976  31  29  31  30  31  30  31  31  30  31  30  31
1977  31  28  31  30  31  30  31  31  30  31  30  31
1978  31  28  31  30  31  30  31  31  30  31  30  31
1979  31  28  31  30  31  30  31  31  30  31  30  31
1980  31  29  31  30  31  30  31  31  30  31  30  31
1981  31  28  31  30  31  30  31  31  30  31  30  31
1982  31  28  31  30  31  30  31  31  30  31  30  31
1983  31  28  31  30  31  30  31  31  30  31  30  31
1984  31  29  31  30  31  30  31  31  30  31  30  31
1985  31  28  31  30  31  30  31  31  30  31  30  31
1986  31  28  31  30  31  30  31  31  30  31  30  31
1987  31  28  31  30  31  30  31  31  30  31  30  31
1988  31  29  31  30  31  30  31  31  30  31  30  31
1989  31  28  31  30  31  30  31  31  30  31  30  31
1990  31  28  31  30  31  30  31  31  30  31  30  31

hydroTSM documentation built on March 13, 2020, 2:23 a.m.