Description Usage Arguments Details Value Author(s) Examples
View source: R/timeIntegration.R
Integrate a series over time by calculating the area under the "curve" of the linear interpolation of the series (akin to the Trapezoid rule). This is especially useful in calculating energy usage: kilowatt-hours, watt-seconds, etc.
1 2 3 |
data |
Vector of numerical data |
time |
Vector of timestamps which correspond to |
lower |
The time (character or POSIXct) of the lower bound of the integration |
upper |
The time (character or POSIXct) of the upper bound of the integration |
check.plot |
|
units |
The units of integration, defaults to hours. It is only required to supply enough characters to uniquely complete the name. |
If upper
or lower
does not correspond to a data point, a
linear interpolation is made between the two neighboring time points to
predict the resulting data value.
The approximation of the integral by joining the points in the series in a linear fashion and calculating the area under this "curve".
Landon Sego
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Some example power data
data(PowerData)
par(mfrow = c(2, 1))
# Calculate the kilowatt-minutes, display graph which shows how the
# integration is done. This example calculates the integral using
# a contiguous subset of the data
int1 <- timeIntegration(PowerData,
# Convert to POSIXct in order to subtract time
lower = "5/6/2008 17:00:09",
upper = "5/6/2008 17:01:36",
check.plot = TRUE, units = "m")
# This example calculates the integral for all the data in 'powerData'
int2 <- timeIntegration(PowerData, check.plot = TRUE, units = "m")
# Print the outcome
pvar(int1, int2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.