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.
1 2 3 4 5 
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. 
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.
Object of class rose
Rene Locher
roseclass, plot.rose, cart2clock
,
clock2cart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34  ## 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

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.