Description Usage Arguments Value Examples
Cast a data frame to a "zoocat
" object. The data frame should be
a long format data frame (for example, melted by reshape2::melt
).
1 2 | cast2zoocat(x, index.var, value.var, attr.var = NULL, fun.aggregate = NULL,
del.unique.cattr = TRUE)
|
x |
a data frame. |
index.var |
the name of the column to be treated as the index of the
|
value.var |
the name of the column which stored the values. |
attr.var |
the name of the column which will be used as column attributes of
the |
fun.aggregate |
aggregation function needed if variables do not identify a single observation
for each output cell. Defaults to length (with a message) if needed but not specified.
See |
del.unique.cattr |
logical. If TRUE, the column attibutes with unique value will be deleted. |
a "zoocat
" object.
1 2 3 4 5 6 7 8 9 10 11 12 | df <- data.frame(year = rep(1991 : 1995, each = 24), month = rep(1 : 12, 10),
varname = rep(c('a', 'b'), each = 12), city = rep(1 : 3, each = 40),
value = 1 : 120)
cast2zoocat(df, index.var = 'year', value.var = 'value')
cast2zoocat(df, index.var = 'year', value.var = 'value', attr.var = 'varname')
## This is the air quality example from package reshape2
names(airquality) <- tolower(names(airquality))
aqm <- melt(airquality, id = c("month", "day"), na.rm=TRUE)
head(aqm)
cast2zoocat(aqm, index.var = 'month', value.var = 'value', attr.var = 'variable')
cast2zoocat(aqm, index.var = 'month', value.var = 'value')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.