| parseStats | R Documentation |
The functions unparseStats and stats2json serialize the
statistics as a JSON record. The function parseStats reverses
the process.
parseStats(slist)
unparseStats(slist, flatten=FALSE)
stats2json(slist, flatten=FALSE)
slist |
A list of statistics. For |
flatten |
If true, then vector-valued statistics (i.e.,
|
The function unparseStats massages the list of statistics so it
will be output in clean JSON (in particular, using
unboxer to make sure scalars appear as scalars
and not vectors). The function stats2json is just
toJSON(unparseStats(slist)).
If flatten is true, then vector value statstics will be
flattened. For example, if the statistic “Physics_Margin” has
three values with labels “High”, “Medium”, and
“Low”, then it will be replaced with three statistics with the
names “Physics_Margin.High”, “Physics_Margin.Medium”,
and “Physics_Margin.Low”.
The function parseStatistics is designed to reverse the
process.
The function unparseStats returns a list which is ready to be
passed to toJSON. In particular, scalars are
marked using unboxer.
The function stats2json returns a string containing the JSON.
The function parseStats returns a list of statistics values.
this is suitable for being set to the stats field of the
StudentRecord object.
When using flatten=TRUE, avoid periods, ‘.’, in the
names of statistics, as this marker is used to recreate the nested
structure in parseStats.
Russell Almond
buildObject gives general information about how
the parsing/unparsing protocol works.
Statistic gives a list of available statistics.
StudentRecord talks about the statitic fields of
the student records.
stats <- list(Physics_EAP=0,EnergyTransfer_EAP=.15,
Physics_Margin=c(High=1/3,Medium=1/3,
Low=1/3))
stats2json(stats)
stats1 <- parseStats(ununboxer(unparseStats(stats)))
stopifnot(all.equal(stats,stats1,tolerance=.0002))
stats2json(stats,flatten=TRUE)
stats2 <- parseStats(ununboxer(unparseStats(stats,flatten=TRUE)))
stopifnot(all.equal(stats,stats2,tolerance=.0002))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.