# DAL ToolBox
# version 1.1.727
source("https://raw.githubusercontent.com/cefet-rj-dal/daltoolbox/main/jupyter.R")
#loading DAL
load_library("daltoolbox")
Loading required package: daltoolbox Registered S3 method overwritten by 'quantmod': method from as.zoo.data.frame zoo Attaching package: ‘daltoolbox’ The following object is masked from ‘package:base’: transform
load_library("ggplot2")
load_library("RColorBrewer")
#color palette
colors <- brewer.pal(4, 'Set1')
# setting the font size for all charts
font <- theme(text = element_text(size=16))
Loading required package: ggplot2 Loading required package: RColorBrewer
#iris dataset for the example
head(iris)
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species | |
---|---|---|---|---|---|
<dbl> | <dbl> | <dbl> | <dbl> | <fct> | |
1 | 5.1 | 3.5 | 1.4 | 0.2 | setosa |
2 | 4.9 | 3.0 | 1.4 | 0.2 | setosa |
3 | 4.7 | 3.2 | 1.3 | 0.2 | setosa |
4 | 4.6 | 3.1 | 1.5 | 0.2 | setosa |
5 | 5.0 | 3.6 | 1.4 | 0.2 | setosa |
6 | 5.4 | 3.9 | 1.7 | 0.4 | setosa |
load_library("dplyr")
data <- iris |> group_by(Species) |> summarize(Sepal.Length=mean(Sepal.Length))
head(data)
Loading required package: dplyr Attaching package: ‘dplyr’ The following objects are masked from ‘package:stats’: filter, lag The following objects are masked from ‘package:base’: intersect, setdiff, setequal, union
Species | Sepal.Length |
---|---|
<fct> | <dbl> |
setosa | 5.006 |
versicolor | 5.936 |
virginica | 6.588 |
The lollipop graph has the same goal as a bar graph.
grf <- plot_lollipop(data, colors=colors[1], max_value_gap=0.2) + font
plot(grf)
grf <- plot_lollipop(data, colors=colors[1], max_value_gap=0.1) + font + coord_flip()
plot(grf)