rose {IDPmisc} | R Documentation |
Creates a rose object out of circular data
Description
rose
splits data into subsets according to one or two
grouping elements, computes summary statistics for each, and returns
the result in a rose object.
Usage
rose(x, subset = NULL,
cyclVar = NULL, circle = NULL, n.cyclVar = 8,
cut = NULL, labels = NULL,
breaks = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 2,
warn = TRUE, FUN = mean, ...)
Arguments
x |
Vector, data frame or matrix containing the response. |
subset |
An optional vector specifying a subset of observations to be used in the aggregating process. |
cyclVar |
Cyclic variable as first grouping
element. |
circle |
Defines the value of a full circle with no default. |
n.cyclVar |
Defines the number of equally spaced intervals of the cyclic variable, into which the data are split. The first interval is labeled with 0 and is always centered around 0. |
cut |
Vector of numerics, logicals or factors as second grouping
elements. Its length is equal to the number of rows in
|
labels |
Labels for the corresponding intervals. When cut is a logical, labels has to be named in the order: FALSE, TRUE. |
breaks , include.lowest , right , dig.lab |
These arguments are
only active when |
warn |
Logical, indicating if warnings should be issued
for NAs in |
FUN |
Summary function, returning a scalar or vector. |
... |
Additional arguments for summary function. |
Details
The first grouping element, cyclVar
, for the summary statistics
must be circular and numeric. The second grouping element, cut
,
can be numeric, logical or a factor.
Not all combinations of arguments are allowed:
Argument cut
can only be defined when summary consists of a
scalar and x
consists of 1 column.
When x
contains only one column and cut
is not
defined, the summary function may also be a vector with the
restriction, that the summary of each subset, defined by the cyclic
variable, must have the same number of elements.
When x
is a data frame or matrix with more than 1 column,
the summary function must be scalar.
Value
Object of class rose
Author(s)
Rene Locher
See Also
rose-class, plot.rose, cart2clock
,
clock2cart
Examples
## artificial example:
## concentration of A and B as function of
## hour of day (hour) and wind direction (WD)
hour <- rep(0:23,100)
dat <- data.frame(hour = hour,
A = (2*cos((hour+6)/6*pi)+rnorm(24*100,1))^2,
B = (2*cos((hour+4)/6*pi)+rnorm(24*100,1,2))^2,
WD = rnorm(24*100,
mean=sample(c(190,220,50),24*100, replace = TRUE),
sd=30)%%360)
## two different responses, scalar summary function
mean.windrose <- rose(dat[,c("A","B")],
cyclVar=dat$WD,
circle=360,
FUN=mean, na.rm=TRUE)
mean.windrose
## one response, vectorial summary function
quant.dayrose <- rose(dat$A,
cyclVar=dat$hour,
n.cyclVar=24, circle=24,
FUN=quantile, na.rm=TRUE)
quant.dayrose
mean.windroseB <- rose(dat[,c("A")],
cyclVar=dat$WD,
circle=360,
cut=dat$B,
breaks=c(0,30,100),
dig.lab=3,
FUN=mean, na.rm=TRUE)
mean.windroseB