Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

extract

Extract from Zoo


Description

Extracts from a zoo object all the values belonging to a given month, year or weather season.

Usage

extract(x, ...)

## Default S3 method:
extract(x, trgt, ...)
     
## S3 method for class 'zoo'
extract(x, trgt, ...)

Arguments

x

zoo object

trgt

numeric or character indicating the elements to extract from x. Valid values are:
1) integer(s) from 1 to 12: trgt is considered as month(s) (1=JAN, 2=FEB,...., 12=DEC), and all the values in x belonging to the month(s) specified by trgt will be extracted.
2) integer(s) > 12: trgt is considered as year(s), and all the values in x belonging to the year(s) specified by trgt will be extracted
3) character: trgt is considered as a weather season, and all the values in x belonging to the season specified by trgt will be extracted. Valid values are:
-) DJF : December, January, February
-) MAM : March, April, May
-) JJA : June, July, August
-) SON : September, October, November
-) DJFM: December, January, February, March
-) AM : April, May
-) JJAS: June, July, August, September
-) ON : October, November

...

further arguments passed to or from other methods

Value

a zoo object with the extracted values.

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See Also

Examples

### Loading temperature data ##
data(SanMartinoPPts)
x <- SanMartinoPPts

## Extracting all the values belonging to February (FEB=2)
extract(x, trgt=2)

## Extracting all the values belonging to February (FEB=2) and April (APR=4)
extract(x, trgt=c(2,4))

## Extracting all the values belonging to the year 1970
extract(x, trgt=1970)

## Extracting all the values belonging to the years 1970 and 1972
extract(x, trgt=c(1970,1972))

## Extracting all the values belonging to the autumn
extract(x, trgt="SON")

hydroTSM

Time Series Management, Analysis and Interpolation for Hydrological Modelling

v0.6-0
GPL (>= 2)
Authors
Mauricio Zambrano-Bigiarini [aut, cre, cph] (<https://orcid.org/0000-0002-9536-643X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.