data <- read_csv("../Desktop/PSU_DAT3000_IntroToDA/00_data/Mydata.csv")
## New names:
## Rows: 41152 Columns: 17
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (11): Name, Sex, Event, Equiptment, Age Class, Division, Weight Class KG... dbl
## (5): Age, Bodyweight, Best Sqaut KG, Best Bench KG, Best Deadlifting lgl (1):
## ...17
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...17`
Make two bar charts here - one before ordering another after
# Plot Before
data %>%
ggplot(aes(x = Sex , y = `Weight Class KG`)) +
geom_point()
# Plot After
Show examples of three functions:
data %>% count(Event)
## # A tibble: 3 × 2
## Event n
## <chr> <int>
## 1 B 12564
## 2 SB 2
## 3 SBD 28586
data %>%
mutate(Event_Rev = fct_recode(Event,
"Bench" = "B",
"SquatBench" = "SB",
"SquatBenchDeadlift" = "SBD")) %>%
select(Event, Event_Rev) %>%
sample_n(10)
## # A tibble: 10 × 2
## Event Event_Rev
## <chr> <fct>
## 1 SBD SquatBenchDeadlift
## 2 B Bench
## 3 SBD SquatBenchDeadlift
## 4 B Bench
## 5 B Bench
## 6 SBD SquatBenchDeadlift
## 7 B Bench
## 8 B Bench
## 9 SBD SquatBenchDeadlift
## 10 B Bench
data %>%
mutate(Event_col = fct_collapse(Event,
lift_heavy = c("SB", "SBD"),
lift_light = c("B"))
) %>%
select(Event, Event_col) %>%
sample_n(3)
## # A tibble: 3 × 2
## Event Event_col
## <chr> <fct>
## 1 SBD lift_heavy
## 2 SBD lift_heavy
## 3 SBD lift_heavy
data %>% count(Event, sort = T)
## # A tibble: 3 × 2
## Event n
## <chr> <int>
## 1 SBD 28586
## 2 B 12564
## 3 SB 2
data%>%
mutate(Event_lump = fct_lump(Event, n = 2)) %>%
select(Event, Event_lump)
## # A tibble: 41,152 × 2
## Event Event_lump
## <chr> <fct>
## 1 B B
## 2 B B
## 3 B B
## 4 B B
## 5 B B
## 6 B B
## 7 B B
## 8 B B
## 9 B B
## 10 B B
## # … with 41,142 more rows
No need to do anything here.