..sumprop..
, ..sumpct..
count
and count2d
StatisticsComputed variables ..sumprop..
and ..sumpct..
take the value of the share of observations at a given location relative to the total number of observations.
This is in contrast to computed variables ..prop..
and ..proppct..
which take the value of the share of observations belonging to a given group relative to the number of observations at a given location.
%useLatestDescriptors
%use lets-plot
%use dataframe
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.6.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.2.0.
val data = mapOf(
"x" to listOf('a', 'a', 'a', 'a', 'b', 'b'),
"group" to listOf('A', 'A', 'A', 'B', 'A', 'B')
)
val tooltipOptions = layerTooltips("..sumprop..", "..sumpct..", "..prop..", "..proppct..")
..sumprop..
and ..sumpct..
for Plots without Grouping¶Note: compare vaues shown in the tooltip.
letsPlot(data) { x = "x" } +
geomBar(tooltips = tooltipOptions, labels = layerLabels().line("@..sumprop.. (@..sumpct..)"))
..prop..
, ..proppct..
Better Suit for Grouped Plots¶Note: again, compare vaues shown in the tooltip.
letsPlot(data) { x = "x"; fill = "group" } +
geomBar(tooltips = tooltipOptions, labels = layerLabels().line("@..prop.. (@..proppct..)"))
count2d
Stat Works Similarly¶val mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg.head(3)
DataFrame: rowsCount = 3, columnsCount = 12
untitled | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | audi | a4 | 1.800000 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
2 | audi | a4 | 1.800000 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
3 | audi | a4 | 2.000000 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
letsPlot(mpg.toMap()) { x = "drv"; y = asDiscrete("year") } +
geomPie(tooltips = tooltipOptions) { fill = "class"; size = "..sum.." } +
scaleSize(guide = "none")