Import your data
library(tidyverse)
data <- read_csv("../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`
skimr::skim(data)
Data summary
| Name |
data |
| Number of rows |
41152 |
| Number of columns |
17 |
| _______________________ |
|
| Column type frequency: |
|
| character |
11 |
| logical |
1 |
| numeric |
5 |
| ________________________ |
|
| Group variables |
None |
Variable type: character
| Name |
0 |
1.00 |
2 |
36 |
0 |
17805 |
0 |
| Sex |
0 |
1.00 |
1 |
1 |
0 |
2 |
0 |
| Event |
0 |
1.00 |
1 |
3 |
0 |
3 |
0 |
| Equiptment |
0 |
1.00 |
3 |
10 |
0 |
3 |
0 |
| Age Class |
2884 |
0.93 |
5 |
6 |
0 |
16 |
0 |
| Division |
627 |
0.98 |
4 |
11 |
0 |
12 |
0 |
| Weight Class KG |
1 |
1.00 |
2 |
5 |
0 |
38 |
0 |
| Place |
0 |
1.00 |
1 |
2 |
0 |
34 |
0 |
| Date |
0 |
1.00 |
6 |
8 |
0 |
224 |
0 |
| Federation |
0 |
1.00 |
3 |
3 |
0 |
1 |
0 |
| Meet Name |
0 |
1.00 |
11 |
54 |
0 |
32 |
0 |
Variable type: logical
Variable type: numeric
| Age |
2906 |
0.93 |
34.77 |
14.62 |
0.50 |
22.5 |
31.50 |
45.0 |
93.5 |
▂▇▅▂▁ |
| Bodyweight |
187 |
1.00 |
81.15 |
24.93 |
37.29 |
60.0 |
75.55 |
97.3 |
240.0 |
▇▆▂▁▁ |
| Best Sqaut KG |
13698 |
0.67 |
217.55 |
74.61 |
-210.00 |
160.0 |
215.00 |
270.0 |
490.0 |
▁▁▇▇▁ |
| Best Bench KG |
2462 |
0.94 |
144.68 |
60.03 |
-160.00 |
97.5 |
140.00 |
185.0 |
415.0 |
▁▁▇▃▁ |
| Best Deadlifting |
14028 |
0.66 |
221.84 |
63.72 |
-215.00 |
170.0 |
222.50 |
270.0 |
420.0 |
▁▁▃▇▂ |
data_small <- data %>%
select(Sex, Event, `Best Bench KG`) %>%
sample_n(10)
Separating and Uniting
Unite two columns
?unite
data_unite <- data_small %>%
unite(col = "Sex_Event", Event, Sex, sep = "_")
data_unite[10,1] <- "SBD_M_event"
data_unite
## # A tibble: 10 × 2
## Sex_Event `Best Bench KG`
## <chr> <dbl>
## 1 B_M 100
## 2 B_F 90
## 3 SBD_F 65
## 4 SBD_M 195
## 5 SBD_M 140
## 6 B_F 82.5
## 7 SBD_M 158.
## 8 SBD_M 230
## 9 SBD_F NA
## 10 SBD_M_event 100
Separate a column
data_unite %>%
separate(col = Sex_Event, into = c("Sex", "event"), sep = "_")
## Warning: Expected 2 pieces. Additional pieces discarded in 1 rows [10].
## # A tibble: 10 × 3
## Sex event `Best Bench KG`
## <chr> <chr> <dbl>
## 1 B M 100
## 2 B F 90
## 3 SBD F 65
## 4 SBD M 195
## 5 SBD M 140
## 6 B F 82.5
## 7 SBD M 158.
## 8 SBD M 230
## 9 SBD F NA
## 10 SBD M 100