Skip to contents

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

Usage

extract(x, ...)

# S3 method for default
extract(x, trgt, ...)
     
# S3 method for 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

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

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")