-
Notifications
You must be signed in to change notification settings - Fork 705
/
Copy path037_dataeditr.R
66 lines (43 loc) · 1.29 KB
/
037_dataeditr.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# BUSINESS SCIENCE R TIPS ----
# R-TIP 037 | DataEditR: GUI for Data Wrangling in R ----
#
# 👉 For Weekly R-Tips, Sign Up Here:
# https://learn.business-science.io/r-tips-newsletter
# LIBRARIES ----
library(DataEditR)
library(tidyverse)
library(tidyquant)
# DATA ----
mpg
# 1.0 DATA EDITING ----
# 1.1 data_edit() ----
mpg_subset <- data_edit(
x = mpg
)
# 1.2 RStudio Add-In ----
# Addins > Interactive Data Editor
# 2.0 LEARNING MORE -----
# R FOR BUSINESS ANALYSIS COURSE (DS4B 101-R)
# - Learn dplyr in Week 2 (Data Wrangling)
# https://university.business-science.io/p/ds4b-101-r-business-analysis-r
mpg %>%
select(manufacturer, model, cty, hwy, class) %>%
pivot_longer(cols = c(cty, hwy)) %>%
mutate(
model = fct_reorder(
str_glue("{manufacturer} {model}") %>% str_to_title(),
value
),
name = str_to_upper(name)
) %>%
ggplot(aes(x = model, y = value, fill = class)) +
geom_boxplot() +
facet_grid(cols = vars(name), scales = "free_y") +
coord_flip() +
scale_fill_tq() +
theme_tq() +
labs(title = "Fuel Economy by Model", y = "MPG", x = "")
# LEARNING MORE ----
# FREE MASTERCLASS
# - 10 SECRETS TO BECOMING A DATA SCIENTIST
# https://learn.business-science.io/free-rtrack-masterclass