Learn R Programming

RtsEva (version 1.1.0)

tsGetNumberPerYear: tsGetNumberPerYear

Description

tsGetNumberPerYear is a function that calculates the number of events per year based on a given time series and a set of locations.

Usage

tsGetNumberPerYear(ms, locs)

Value

A data frame with two columns: "year" and "Freq". The "year" column contains the years, and the "Freq" column contains the number of events per year.

Arguments

ms

A data frame representing the time series data, where the first column contains the dates of the events.

locs

A vector of indices representing the locations of interest in the time series.

Examples

Run this code
# Create a sample time series data frame
set.seed(123)
ms <- data.frame(date = seq(as.Date("2000-01-01"), as.Date("2022-12-31"), by = "day"),
                values=rnorm(8401))
# Generate random events
events <- match(sample(ms$date, 100),ms$date)
# Get the number of events per year
tsGetNumberPerYear(ms, events)

Run the code above in your browser using DataLab