Create an object describing multi-parameter spatiotemporal data in the (mostly) universal data format. This format is a collection of tables as described below. For an example of data already in this format, see the kentvillegreenwood dataset.
mudata(data, locations = NULL, params = NULL, datasets = NULL,
columns = NULL, dataset.id = "default", location.id = "default",
defactorize = TRUE, validate = TRUE, expand.tags = TRUE,
retype = FALSE)
The data table, which is a molten data frame containing the columns (at least)
'dataset', 'location', 'x', 'param', and 'value'. The 'dataset' column can be omitted
if there is only one dataset contained in the object (its name can be specified by
passing the parameter dataset.id
). The 'location' column can be omitted if
there is only data for one dataset and one location (its name can be specified by
passing the parameter location.id
).
The locations table, which is a data frame containing the columns (at least) 'datset', and 'location'. If omitted, it will be created automatically using all unique dataset/location combinations.
The params table, which is a data frame containing the columns (at least) 'datset', and 'param'. If omitted, it will be created automatically using all unique dataset/param combinations.
The datasets table, which is a data frame containing the column (at least) 'dataset'. If omitted, it will be generated automatically using all unique datasets.
The columns table, which is a data frame containing the columns (at least) 'dataset', 'table', and 'column'. If omitted, it will be created automatically using all dataset/table/column combinations.
The dataset id to use if the datasets table is omitted.
The location id if the locations table is omitted.
Pass FALSE
to suppress coersion of 'dataset', 'location', and 'param'
columns to type 'character'.
Pass FALSE
to skip validation of input tables.
Pass FALSE
to collapse non-required columns to a single column
(called 'tags'), with key/value pairs in JSON format. See expand.tags.
Pass TRUE
to retype columns based on the 'type' column of the 'columns'
table. This is useful when reading data from disk, where date/time columns may be stored
as text.
A mudata
object
# NOT RUN {
library(reshape2)
library(dplyr)
data(pocmaj)
# melt data and summarise replicates
datatable <- pocmaj %>%
melt(id.vars=c("core", "depth"), variable.name="param") %>%
group_by(core, param, depth) %>%
summarise(sd=mean(value), value=mean(value)) %>%
rename.cols("depth"="x", "core"="location")
# create mudata object
md <- mudata(datatable)
summary(md)
plot(md, yvar="x", geom=c("path", "point"))
# }
Run the code above in your browser using DataLab