This tuturial is the part of the dplyr training series. Here is the YouTube Video link for this tutuorial.
library(echarts4r)
## Warning: package 'echarts4r' was built under R version 4.1.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.1.3
In Sep 2022 there was a cyber attack on Optus which exposed the data of 10 million Australians, while the total population of Australia at this time was 25.9 million. So a sizeable proportion of the population has been adversely affected.
Here is our data based on these facts.
TotalPop <- 25.9
Exposed <- 9.8
NotExposed <- TotalPop -Exposed
df <- data.frame(characteristic = c('Not Exposed','Exposed')
, value = c(NotExposed, Exposed))
df <- df%>%
dplyr::group_by()%>%
dplyr::mutate(pct = value/sum(value))
df <- df%>%
dplyr::mutate(characteristic = paste(characteristic , scales::percent(pct)))
df |>
e_charts(characteristic) |>
e_pie(value) |>
e_color(color = c('Green','Red'))