The synthax of g2r is heavily inspired by ggplot2.
|From ggplot2 to g2r|
In g2r you use aspects (
asp) instead of aesthetics (
aes) in ggplot2 but they work in very much the same way.
Then you can use gauges (instead of scales in ggplot2) to manipulate those aspects.
g2(cars, asp(dist, speed, color = speed, size = speed)) %>% fig_point() %>% gauge_color(c("blue", "white", "red"))
It may seem like some some figures (equivalent to geoms) are missing, but technically all are available.
fruits %>% arrange(-value) %>% g2(asp(value, color = fruit)) %>% fig_interval_stack() %>% coord_type("theta")
The same could be said of the funnel.
You won’t find
fig_interval does the trick. Below we use the
adjust function which is similar to using the
stat argument in ggplot2.
g2(temp, asp(month, temp, color = city)) %>% fig_interval(adjust("dodge")) # equivalent to fig_interval_dodge
g2(temp, asp(month, temp, color = city)) %>% fig_interval(adjust("stack")) # equivalent to fig_interval_stack
There is a
fig_violin but it expects the data in a specific format, so a helper function exists,
A heatmap is easier.