View source: R/calcPercentile.R
calcPercentile | R Documentation |
Calculates multiple percentile values from a time series, with flexible time
aggregation. This function is a wrapper for timeAverage()
, making it easier
to calculate several percentiles at once. Like timeAverage()
, it requires a
data frame with a date
field and one other numeric variable.
calcPercentile(
mydata,
pollutant = "o3",
avg.time = "month",
percentile = 50,
type = "default",
data.thresh = 0,
start.date = NA,
end.date = NA,
prefix = "percentile."
)
mydata |
A data frame containing a |
pollutant |
Name of column containing variable to summarise, likely a
pollutant (e.g., |
avg.time |
This defines the time period to average to. Can be Note that |
percentile |
A vector of percentile values; for example, |
type |
|
data.thresh |
The data capture threshold to use (%). A value of zero
means that all available data will be used in a particular period
regardless if of the number of values available. Conversely, a value of 100
will mean that all data will need to be present for the average to be
calculated, else it is recorded as |
start.date |
A string giving a start date to use. This is sometimes
useful if a time series starts between obvious intervals. For example, for
a 1-minute time series that starts |
end.date |
A string giving an end date to use. This is sometimes useful
to make sure a time series extends to a known end point and is useful when
|
prefix |
Each new column is named by appending a |
Returns a data.frame
with a date
column plus an additional
column for each given percentile
.
David Carslaw
timePlot()
, timeAverage()
# 95th percentile monthly o3 concentrations
percentiles <- calcPercentile(mydata,
pollutant = "o3",
avg.time = "month", percentile = 95
)
head(percentiles)
# 5, 50, 95th percentile monthly o3 concentrations
## Not run:
percentiles <- calcPercentile(mydata,
pollutant = "o3",
avg.time = "month", percentile = c(5, 50, 95)
)
head(percentiles)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.