forked from business-science/free_r_tips
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# R TIPS ---- | ||
# TIP 050 | Trelliscope JS: Interactive Data Visualization with ggplot ---- | ||
# | ||
# 👉 For Weekly R-Tips, Sign Up Here: | ||
# https://learn.business-science.io/r-tips-newsletter | ||
|
||
# Documentation: https://hafen.github.io/trelliscopejs/ | ||
|
||
# INSTALLATION ---- | ||
# install.packages("trelliscopejs") | ||
|
||
|
||
# LIBRARIES ---- | ||
|
||
library(tidyverse) | ||
library(plotly) | ||
library(trelliscopejs) | ||
|
||
# DATA ---- | ||
|
||
mpg | ||
|
||
# 1.0 GGPLOT ---- | ||
# - Add Labels: Displ Min/Max, Hwy Min/Max/Mean | ||
|
||
mpg %>% | ||
ggplot(aes(displ, hwy)) + | ||
geom_point(size = 4) + | ||
geom_smooth(se = FALSE, span = 1) + | ||
facet_trelliscope( | ||
~ manufacturer, | ||
ncol = 4, | ||
nrow = 3 | ||
) | ||
|
||
|
||
# 2.0 MEGA BONUS: INTERACTIVE (plotly) ---- | ||
|
||
mpg %>% | ||
ggplot(aes(displ, hwy)) + | ||
geom_point() + | ||
geom_smooth(se = FALSE, span = 1) + | ||
facet_trelliscope( | ||
~ manufacturer, | ||
ncol = 4, | ||
nrow = 3, | ||
as_plotly = TRUE | ||
) | ||
|
||
|
||
|
||
# LEARNING MORE ---- | ||
|
||
# FREE MASTERCLASS | ||
# - 10 SECRETS TO BECOMING A DATA SCIENTIST | ||
# https://learn.business-science.io/free-rtrack-masterclass | ||
|