+ - 0:00:00
Notes for current slide
Notes for next slide
These slides are viewed best by Chrome and occasionally need to be refreshed if elements did not load properly. See here for PDF .
1/26

Tidyverse Workshop



Data wrangling with dplyr & tidyr

Presented by Emi Tanaka

School of Mathematics and Statistics


dr.emi.tanaka@gmail.com @statsgen

1st Dec 2019 @ Biometrics by the Botanic Gardens | Adelaide, Australia

1/26

🎯 Aim: using this data, plot below graph

glimpse(dat)
Observations: 535
Variables: 5
$ CD <dbl> 28, 27, 31, 33, 26, 31, 33, 28, 29, 34, 27, 29, 25, 33, 24, 30, 23, 34, 28, 27, 30, 27, 26, 33, 33, 33, 34, 27, 32, 26, 32, 34, 24, 31, 29, 27, 29, 34, 28, 33, 24, 29, 23, 32, 32, 33, 26, 25, 32, 21, 37, 33, 33, 36, 24, 32, 34, 31, 25, 36, 24, 31, 28, 27, 29, 34, 29, 28, 34, 27, 23, 33, 32, 32, 23, 24, 32, 23, 34, 22, 29, 28, 33, 30, 33, 29, 36, 33, 34, 32, 28, 29, 31, 28, 34, 25, 22, 36, 29, 31, 28, 26, 27, 34, 29, 35, 31, 33, 32, 31, 26, 28, 29, 30, 35, 30, 28, 32, 33, 26, 35, 33, 33, 32, 31, 24, 23, 32, 28, 30, 29, 23, 29, 30, 29, 34, 30, 32, 30, 28, 23, 31, 26, 25, 33, 30, 28, 26, 28, 31, 24, 35, 33, 34, 24, 28, 31, 24, 30, 36, 35, 25, 29, 32, 30, 33, 29, 26, 29, 27, 29, 28, 35, 33, 37, 34, 35, 29, 25, 29, 26, 31, 30, 30, 29, 29, 31, 32, 29, 35, 30, 29, 30, 25, 33, 37, 30, 31, 31, 33, 25, 22, 27, 30, 26, 30, 31, 26, 35, 34, 28, 26, 24, 31, 34, 33, 28, 29, 30, 30, 34, 36, 31, 29, 23, 35, 27, 26, 25, 35, 32, 34, 33, 34, 33, 27, 23, 30, 25, 24, 27, 31, 25, 25, 32, 31, 27
$ CR <dbl> 12, 15, 13, 15, 11, 6, 15, 12, 14, 12, 9, 8, 10, 7, 11, 10, 13, 14, 7, 16, 14, 7, 8, 10, 8, 13, 13, 10, 13, 11, 8, 12, 16, 15, 8, 12, 13, 14, 6, 13, 9, 11, 13, 11, 14, 17, 9, 13, 12, 9, 13, 9, 9, 14, 15, 12, 13, 10, 7, 14, 15, 8, 11, 11, 7, 13, 14, 14, 12, 16, 14, 7, 11, 9, 16, 10, 7, 10, 10, 10, 7, 8, 13, 12, 14, 15, 8, 7, 13, 7, 9, 11, 12, 10, 18, 9, 6, 11, 9, 11, 14, 8, 10, 13, 13, 9, 15, 10, 16, 9, 12, 11, 14, 11, 15, 10, 12, 17, 12, 8, 16, 8, 6, 10, 11, 10, 13, 8, 12, 11, 12, 12, 11, 13, 9, 11, 9, 11, 13, 9, 12, 6, 11, 11, 8, 8, 8, 7, 6, 10, 15, 10, 11, 11, 10, 12, 14, 14, 13, 13, 11, 13, 7, 15, 11, 16, 12, 14, 13, 15, 16, 9, 9, 7, 16, 12, 9, 8, 14, 12, 13, 14, 10, 8, 8, 12, 12, 10, 7, 13, 11, 12, 12, 11, 12, 13, 15, 18, 12, 9, 13, 13, 16, 9, 7, 12, 10, 6, 13, 12, 15, 10, 11, 12, 16, 13, 10, 8, 9, 8, 15, 7, 15, 12, 14, 9, 13, 10, 15, 8, 10, 10, 9, 15, 12, 10, 15, 17, 11, 13, 10, 12, 12, 9, 13, 12, 12, 15, 7, 8, 6, 12, 12, 8, 13, 12, 8, 7, 12, 11, 10, 14, 6, 11, 10, 1
$ DF <dbl> 2315, 2304, 2646, 2281, 2789, 2719, 2233, 2667, 2527, 2574, 2360, 2380, 2535, 2482, 2485, 2302, 2370, 2316, 2506, 2230, 2432, 2481, 2737, 2612, 2382, 2774, 2415, 2447, 2241, 2595, 2537, 2718, 2413, 2526, 2450, 2727, 2583, 2557, 2229, 2436, 2440, 2262, 2449, 2789, 2439, 2536, 2452, 2713, 2262, 2388, 2529, 2528, 2781, 2328, 2498, 2500, 2802, 2549, 2386, 2169, 2818, 2402, 2282, 2436, 2546, 2524, 2204, 2519, 2524, 2423, 2425, 2310, 2308, 2634, 2265, 2443, 2484, 2728, 2267, 2584, 2183, 2858, 2437, 2526, 2423, 2185, 2540, 2586, 2727, 2832, 2729, 2725, 2748, 2504, 2523, 2579, 2597, 2475, 2159, 2737, 2392, 2383, 2705, 2434, 2674, 2672, 2603, 2776, 2611, 2588, 2575, 2890, 2667, 2614, 2434, 2434, 2423, 2396, 2422, 2638, 2744, 2249, 2451, 2631, 2444, 2133, 2443, 2624, 2639, 2670, 2571, 2771, 2685, 2589, 2773, 2573, 2863, 2816, 2588, 2515, 2569, 2575, 2600, 2224, 2610, 2621, 2176, 2615, 2149, 2144, 2569, 2610, 2423, 2669, 2669, 2616, 2960, 2412, 2454, 2641, 2684, 2456, 2408, 2649, 27
$ RA <dbl> -10, -8, -12, -7, -8, -6, -12, -16, -12, -10, -12, -12, -6, -15, -12, -10, -12, -8, -14, -15, -12, -18, -14, -11, -13, -7, -6, -13, -8, -5, -12, -13, -14, -10, -21, -13, -7, -11, -16, -9, -11, -7, -8, -15, -13, -12, -11, -9, -12, -14, -6, -18, -14, -7, -15, -17, -10, -15, -13, -10, -12, -10, -7, -12, -12, -10, -10, -6, -11, -12, -13, -13, -7, -10, -15, -9, -9, -12, -10, -19, -12, -11, -18, -8, -11, -10, -9, -12, -16, -17, -6, -13, -10, -9, -13, -9, -14, -10, -11, -10, -12, -13, -14, -12, -11, -9, -16, -16, -11, -13, -13, -13, -6, -6, -14, -9, -14, -20, -14, -9, -10, -11, -8, -10, -15, -10, -15, -17, -12, -6, -10, -6, -5, -8, -11, -15, -10, -9, -8, -14, -14, -15, -13, -15, -9, -16, -8, -13, -10, -9, -11, -16, -14, -14, -12, -15, -14, -13, -13, -8, -11, -15, -11, -8, -11, -16, -16, -16, -14, -14, -12, -11, -12, -14, -12, -11, -9, -12, -13, -7, -8, -7, -13, -7, -13, -11, -11, -13, -17, -6, -14, -14, -8, -10, -11, -10, -8, -14, -9, -21, -12, -11, -11, -11, -12, -12, -13, -10,…
$ PR <dbl> 46, 49, 43, 50, 57, 51, 46, 55, 56, 45, 47, 50, 57, 57, 52, 46, 51, 59, 44, 44, 42, 54, 46, 48, 51, 47, 48, 51, 47, 47, 49, 49, 55, 49, 44, 49, 57, 49, 48, 47, 48, 50, 54, 48, 51, 44, 53, 50, 47, 51, 53, 52, 46, 44, 50, 47, 47, 53, 47, 47, 46, 48, 52, 50, 51, 46, 52, 42, 51, 64, 48, 48, 52, 52, 54, 50, 47, 49, 48, 55, 52, 51, 50, 43, 44, 55, 47, 51, 51, 51, 42, 51, 54, 47, 46, 48, 52, 49, 48, 50, 46, 45, 45, 50, 51, 45, 55, 48, 45, 50, 46, 49, 47, 47, 49, 49, 53, 53, 49, 42, 51, 46, 47, 51, 50, 45, 46, 57, 58, 51, 47, 47, 45, 48, 46, 54, 48, 46, 45, 44, 56, 51, 44, 54, 45, 55, 49, 44, 53, 49, 48, 51, 46, 55, 42, 47, 47, 53, 53, 47, 46, 49, 44, 55, 46, 50, 58, 58, 61, 57, 56, 52, 50, 44, 45, 55, 47, 51, 52, 50, 53, 55, 50, 43, 55, 47, 48, 49, 49, 61, 50, 48, 50, 52, 47, 50, 49, 49, 44, 47, 51, 53, 53, 48, 49, 47, 46, 52, 45, 47, 55, 43, 49, 51, 54, 43, 51, 49, 50, 45, 50, 46, 51, 49, 47, 48, 46, 43, 44, 48, 48, 53, 48, 49, 58, 56, 42, 47, 57, 54, 52, 50, 45, 48, 47, 51, 48

2/26

🤔 Mapping variable to aesthestic

glimpse(dat)
Observations: 535
Variables: 5
$ CD <dbl> 28, 27, 31, 33, 26, 31, 33, 28, 29, 34, 27, 29, 25, 33, 24, 30, 23, 34, 28, 27, 30, 27, 26, 33, 33, 33, 34, 27, 32, 26, 32, 34, 24, 31, 29, 27, 29, 34, 28, 33, 24, 29, 23, 32, 32, 33, 26, 25, 32, 21, 37, 33, 33, 36, 24, 32, 34, 31, 25, 36, 24, 31, 28, 27, 29, 34, 29, 28, 34, 27, 23, 33, 32, 32, 23, 24, 32, 23, 34, 22, 29, 28, 33, 30, 33, 29, 36, 33, 34, 32, 28, 29, 31, 28, 34, 25, 22, 36, 29, 31, 28, 26, 27, 34, 29, 35, 31, 33, 32, 31, 26, 28, 29, 30, 35, 30, 28, 32, 33, 26, 35, 33, 33, 32, 31, 24, 23, 32, 28, 30, 29, 23, 29, 30, 29, 34, 30, 32, 30, 28, 23, 31, 26, 25, 33, 30, 28, 26, 28, 31, 24, 35, 33, 34, 24, 28, 31, 24, 30, 36, 35, 25, 29, 32, 30, 33, 29, 26, 29, 27, 29, 28, 35, 33, 37, 34, 35, 29, 25, 29, 26, 31, 30, 30, 29, 29, 31, 32, 29, 35, 30, 29, 30, 25, 33, 37, 30, 31, 31, 33, 25, 22, 27, 30, 26, 30, 31, 26, 35, 34, 28, 26, 24, 31, 34, 33, 28, 29, 30, 30, 34, 36, 31, 29, 23, 35, 27, 26, 25, 35, 32, 34, 33, 34, 33, 27, 23, 30, 25, 24, 27, 31, 25, 25, 32, 31, 27
$ CR <dbl> 12, 15, 13, 15, 11, 6, 15, 12, 14, 12, 9, 8, 10, 7, 11, 10, 13, 14, 7, 16, 14, 7, 8, 10, 8, 13, 13, 10, 13, 11, 8, 12, 16, 15, 8, 12, 13, 14, 6, 13, 9, 11, 13, 11, 14, 17, 9, 13, 12, 9, 13, 9, 9, 14, 15, 12, 13, 10, 7, 14, 15, 8, 11, 11, 7, 13, 14, 14, 12, 16, 14, 7, 11, 9, 16, 10, 7, 10, 10, 10, 7, 8, 13, 12, 14, 15, 8, 7, 13, 7, 9, 11, 12, 10, 18, 9, 6, 11, 9, 11, 14, 8, 10, 13, 13, 9, 15, 10, 16, 9, 12, 11, 14, 11, 15, 10, 12, 17, 12, 8, 16, 8, 6, 10, 11, 10, 13, 8, 12, 11, 12, 12, 11, 13, 9, 11, 9, 11, 13, 9, 12, 6, 11, 11, 8, 8, 8, 7, 6, 10, 15, 10, 11, 11, 10, 12, 14, 14, 13, 13, 11, 13, 7, 15, 11, 16, 12, 14, 13, 15, 16, 9, 9, 7, 16, 12, 9, 8, 14, 12, 13, 14, 10, 8, 8, 12, 12, 10, 7, 13, 11, 12, 12, 11, 12, 13, 15, 18, 12, 9, 13, 13, 16, 9, 7, 12, 10, 6, 13, 12, 15, 10, 11, 12, 16, 13, 10, 8, 9, 8, 15, 7, 15, 12, 14, 9, 13, 10, 15, 8, 10, 10, 9, 15, 12, 10, 15, 17, 11, 13, 10, 12, 12, 9, 13, 12, 12, 15, 7, 8, 6, 12, 12, 8, 13, 12, 8, 7, 12, 11, 10, 14, 6, 11, 10, 1
$ DF <dbl> 2315, 2304, 2646, 2281, 2789, 2719, 2233, 2667, 2527, 2574, 2360, 2380, 2535, 2482, 2485, 2302, 2370, 2316, 2506, 2230, 2432, 2481, 2737, 2612, 2382, 2774, 2415, 2447, 2241, 2595, 2537, 2718, 2413, 2526, 2450, 2727, 2583, 2557, 2229, 2436, 2440, 2262, 2449, 2789, 2439, 2536, 2452, 2713, 2262, 2388, 2529, 2528, 2781, 2328, 2498, 2500, 2802, 2549, 2386, 2169, 2818, 2402, 2282, 2436, 2546, 2524, 2204, 2519, 2524, 2423, 2425, 2310, 2308, 2634, 2265, 2443, 2484, 2728, 2267, 2584, 2183, 2858, 2437, 2526, 2423, 2185, 2540, 2586, 2727, 2832, 2729, 2725, 2748, 2504, 2523, 2579, 2597, 2475, 2159, 2737, 2392, 2383, 2705, 2434, 2674, 2672, 2603, 2776, 2611, 2588, 2575, 2890, 2667, 2614, 2434, 2434, 2423, 2396, 2422, 2638, 2744, 2249, 2451, 2631, 2444, 2133, 2443, 2624, 2639, 2670, 2571, 2771, 2685, 2589, 2773, 2573, 2863, 2816, 2588, 2515, 2569, 2575, 2600, 2224, 2610, 2621, 2176, 2615, 2149, 2144, 2569, 2610, 2423, 2669, 2669, 2616, 2960, 2412, 2454, 2641, 2684, 2456, 2408, 2649, 27
$ RA <dbl> -10, -8, -12, -7, -8, -6, -12, -16, -12, -10, -12, -12, -6, -15, -12, -10, -12, -8, -14, -15, -12, -18, -14, -11, -13, -7, -6, -13, -8, -5, -12, -13, -14, -10, -21, -13, -7, -11, -16, -9, -11, -7, -8, -15, -13, -12, -11, -9, -12, -14, -6, -18, -14, -7, -15, -17, -10, -15, -13, -10, -12, -10, -7, -12, -12, -10, -10, -6, -11, -12, -13, -13, -7, -10, -15, -9, -9, -12, -10, -19, -12, -11, -18, -8, -11, -10, -9, -12, -16, -17, -6, -13, -10, -9, -13, -9, -14, -10, -11, -10, -12, -13, -14, -12, -11, -9, -16, -16, -11, -13, -13, -13, -6, -6, -14, -9, -14, -20, -14, -9, -10, -11, -8, -10, -15, -10, -15, -17, -12, -6, -10, -6, -5, -8, -11, -15, -10, -9, -8, -14, -14, -15, -13, -15, -9, -16, -8, -13, -10, -9, -11, -16, -14, -14, -12, -15, -14, -13, -13, -8, -11, -15, -11, -8, -11, -16, -16, -16, -14, -14, -12, -11, -12, -14, -12, -11, -9, -12, -13, -7, -8, -7, -13, -7, -13, -11, -11, -13, -17, -6, -14, -14, -8, -10, -11, -10, -8, -14, -9, -21, -12, -11, -11, -11, -12, -12, -13, -10,…
$ PR <dbl> 46, 49, 43, 50, 57, 51, 46, 55, 56, 45, 47, 50, 57, 57, 52, 46, 51, 59, 44, 44, 42, 54, 46, 48, 51, 47, 48, 51, 47, 47, 49, 49, 55, 49, 44, 49, 57, 49, 48, 47, 48, 50, 54, 48, 51, 44, 53, 50, 47, 51, 53, 52, 46, 44, 50, 47, 47, 53, 47, 47, 46, 48, 52, 50, 51, 46, 52, 42, 51, 64, 48, 48, 52, 52, 54, 50, 47, 49, 48, 55, 52, 51, 50, 43, 44, 55, 47, 51, 51, 51, 42, 51, 54, 47, 46, 48, 52, 49, 48, 50, 46, 45, 45, 50, 51, 45, 55, 48, 45, 50, 46, 49, 47, 47, 49, 49, 53, 53, 49, 42, 51, 46, 47, 51, 50, 45, 46, 57, 58, 51, 47, 47, 45, 48, 46, 54, 48, 46, 45, 44, 56, 51, 44, 54, 45, 55, 49, 44, 53, 49, 48, 51, 46, 55, 42, 47, 47, 53, 53, 47, 46, 49, 44, 55, 46, 50, 58, 58, 61, 57, 56, 52, 50, 44, 45, 55, 47, 51, 52, 50, 53, 55, 50, 43, 55, 47, 48, 49, 49, 61, 50, 48, 50, 52, 47, 50, 49, 49, 44, 47, 51, 53, 53, 48, 49, 47, 46, 52, 45, 47, 55, 43, 49, 51, 54, 43, 51, 49, 50, 45, 50, 46, 51, 49, 47, 48, 46, 43, 44, 48, 48, 53, 48, 49, 58, 56, 42, 47, 57, 54, 52, 50, 45, 48, 47, 51, 48
ggplot(<DATA>, aes(x = <VAR>)) +
geom_histogram() +
facet_wrap(~ <VAR>,
scales = "free_x",
nrow = 1)

3/26

🔧 Data wrangling

Raw data is hardly ever in a format ready for downstream analysis


The data we have

The data we need

4/26

🔧 Data wrangling

Raw data is hardly ever in a format ready for downstream analysis


The data we have

The data we need

ggplot(<DATA>, aes(x = value)) +
geom_histogram() +
facet_wrap(~ name,
scales = "free_x",
nrow = 1)
4/26

🔧 Data wrangling: tidyr::pivot_longer

The following commands all produce the same output on the right:


pivot_longer(dat, cols = c("CD", "CR", "DF", "RA", "PR"))
pivot_longer(dat, cols = c(CD, CR, DF, RA, PR))
pivot_longer(dat, cols = CD:PR)
pivot_longer(dat, cols = everything())

Yup, that's all to take your data from wider form to longer form!

# A tibble: 2,675 x 2
name value
<chr> <dbl>
1 CD 28
2 CR 12
3 DF 2315
4 RA -10
5 PR 46
6 CD 27
7 CR 15
8 DF 2304
9 RA -8
10 PR 49
# … with 2,665 more rows
5/26

Tidy evalution

  • tidyverse packages all employ tidy evalution, which includes non-standard evaluation, through rlang package
  • It's the reason below are the same
pivot_longer(dat,
cols = c("CD", "CR", "DF", "RA", "PR"))
pivot_longer(dat,
cols = c(CD, CR, DF, RA, PR))
  • You've actually been using tidy evalution in ggplot!
6/26

Tidy evalution

  • tidyverse packages all employ tidy evalution, which includes non-standard evaluation, through rlang package
  • It's the reason below are the same
pivot_longer(dat,
cols = c("CD", "CR", "DF", "RA", "PR"))
pivot_longer(dat,
cols = c(CD, CR, DF, RA, PR))
  • You've actually been using tidy evalution in ggplot!

What would happen below?

vars <- c("CD", "CR", "DF", "RA", "PR")
pivot_longer(dat, cols = vars)
6/26

Tidy evalution

  • tidyverse packages all employ tidy evalution, which includes non-standard evaluation, through rlang package
  • It's the reason below are the same
pivot_longer(dat,
cols = c("CD", "CR", "DF", "RA", "PR"))
pivot_longer(dat,
cols = c(CD, CR, DF, RA, PR))
  • You've actually been using tidy evalution in ggplot!

What would happen below?

vars <- c("CD", "CR", "DF", "RA", "PR")
pivot_longer(dat, cols = vars)

What if the object name is in the data?

CD <- c("CD", "CR", "DF", "RA", "PR")
pivot_longer(dat, cols = CD)
6/26

Tidy evalution

  • tidyverse packages all employ tidy evalution, which includes non-standard evaluation, through rlang package
  • It's the reason below are the same
pivot_longer(dat,
cols = c("CD", "CR", "DF", "RA", "PR"))
pivot_longer(dat,
cols = c(CD, CR, DF, RA, PR))
  • You've actually been using tidy evalution in ggplot!

What would happen below?

vars <- c("CD", "CR", "DF", "RA", "PR")
pivot_longer(dat, cols = vars)

What if the object name is in the data?

CD <- c("CD", "CR", "DF", "RA", "PR")
pivot_longer(dat, cols = CD)

To "unquote", you need to use !! (pronounced bang-bang)

CD <- c("CD", "CR", "DF", "RA", "PR")
pivot_longer(dat, cols = !!CD)
6/26

tidyselect

Packages in tidyverse generally use tidyselect

pivot_longer(dat, cols = CD:PR)

Selects all variables starting from CD to PR.

pivot_longer(dat, cols = everything())

Selects every variables.

7/26

signal_dat

Note: the header is slightly modified from original.

Tanner, Jessie C.; Ward, Jessica L.; Shaw, Ruth G.; Bee, Mark A. (2017), Data from: Multivariate phenotypic selection on a complex sexual signal, Dataset, https://doi.org/10.5061/dryad.n50cr

8/26

Non-syntatic variable names

  • Syntatic names consist of letters, digits, . and _ only and begin with letters or . AND also cannot be in reserved words list (?Reserved)
  • You need to surround non-syntatic names with backticks if you wish to refer to them
  • E.g. in signal_dat, "Frog ID" is a variable with non-syntatic name because it has a space in it
  • To select "Frog ID", we use
signal_dat$`Frog ID`
[1] 13196 13197 13198 13206 13207 13208 13211 13275 13276 13277 13273 13274 13266 13298 13310 13309 13312 13313 13311 13333 13334 13336 13364 13362 13374 13383 13376 13456 13461 13462 13463 13464 13465 13466 13467 13469 13470 13472 13473 13475 13476 13477 13478 13480 13481 13482 13483 13485 13486 13487 13488 13489 13490 13491 13492 13493 13497 14001 14002 14004 14005 14006 14007 14008 14009 14018 14019 14020 14010 14021 14032 14033 14034 14036 14037 14038 14039 14040 14057 14058 14059 14060 14061 14063 14065 14066 14067 14068 14069 14070 14071 14082 14083 14084 14085 14086 14088 14089 14090 14091 14093 14094 14119 14121 14124 14125 14127 14128 14129 14130 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14176 14177 14178 14179 14180 14181 14182 14184 14185 14201 14202 14203 14204 14205 14206 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14234 14235 14236 14237 14238 14240 14242 14243 14244 14245 14246 14247
[166] 14248 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14276 14277 14278 14279 14280 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14302 14324 14325 14326 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14353 14354 14355 14356 14386 14387 14388 14389 14391 14392 14378 14379 14380 14393 14394 14395 14396 14397 14398 14402 14404 14414 14415 14416 14417 14418 14419 14421 14422 14424 14425 14426 14427 14428 14429 14430 14440 14441 14442 14443 14444 14445 14446 14447 14449 14450 14452 14453 14454 14455 14456 14457 14458 14459 14460 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14490 14491 14494 14496 14498 14499 14500 14501 14502 14503 14504 14505 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520
[331] 14521 14522 14523 14524 14525 14526 14527 14529 14531 14532 14534 14535 14536 14537 14539 14540 14541 14542 14543 14544 14545 14546 14547 14549 14550 14551 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14569 14570 14571 14572 14573 15001 15002 15003 15004 15006 15007 15008 15009 15010 15011 15012 15014 15015 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15105 15106 15107 15108 15109 15110 15111 15112 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130
[496] 15131 15132 15133 15134 15135 15136 15137 15138 15139 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15153 15154 15155 15156 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175

Wickham (2019) Advanced R. Second edition. Chapman & Hall/CRC

9/26

Rename variable names with dplyr::rename

  • Working with non-syntatic names is often a pain!
  • You can rename a variable using dplyr::rename
signal_cdat <- rename(signal_dat,
frog_id = `Frog ID`,
two_choice_latency = `Two Choice Latency`,
two_choice = `Two Choice`,
phonotaxis_score = `Phonotaxis Score`,
speaker_position = `Speaker Position`,
first_presented = `First Presented`)
10/26

Clean variable names

  • But it's still a pain to rename one-by-one
  • The janitor package is fantastic way to clean at once
signal_cdat <- janitor::clean_names(signal_dat)
glimpse(signal_cdat)
Observations: 535
Variables: 18
$ frog_id <dbl> 13196, 13197, 13198, 13206, 13207, 13208, 13211, 13275, 13276, 13277, 13273, 13274, 13266, 13298, 13310, 13309, 13312, 13313, 13311, 13333, 13334, 13336, 13364, 13362, 13374, 13383, 13376, 13456, 13461, 13462, 13463, 13464, 13465, 13466, 13467, 13469, 13470, 13472, 13473, 13475, 13476, 13477, 13478, 13480, 13481, 13482, 13483, 13485, 13486, 13487, 13488, 13489, 13490, 13491, 13492, 13493, 13497, 14001, 14002, 14004, 14005, 14006, 14007, 14008, 14009, 14018, 14019, 14020, 14010, 14021, 14032, 14033, 14034, 14036, 14037, 14038, 14039, 14040, 14057, 14058, 14059, 14060, 14061, 14063, 14065, 14066, 14067, 14068, 14069, 14070, 14071, 14082, 14083, 14084, 14085, 14086, 14088, 14089, 14090, 14091, 14093, 14094, 14119, 14121, 14124, 14125, 14127, 14128, 14129, 14130, 14137, 14138, 14139, 14140, 14141, 14142, 14143, 14144, 14145, 14146, 14147, 14176, 14177, 14178, 14179, 14180, 14181, 14182, 14184, 14185, 14201, 14202, 14203, 14204, 14205, 14206, 14208, 14209, 1421
$ cd <dbl> 28, 27, 31, 33, 26, 31, 33, 28, 29, 34, 27, 29, 25, 33, 24, 30, 23, 34, 28, 27, 30, 27, 26, 33, 33, 33, 34, 27, 32, 26, 32, 34, 24, 31, 29, 27, 29, 34, 28, 33, 24, 29, 23, 32, 32, 33, 26, 25, 32, 21, 37, 33, 33, 36, 24, 32, 34, 31, 25, 36, 24, 31, 28, 27, 29, 34, 29, 28, 34, 27, 23, 33, 32, 32, 23, 24, 32, 23, 34, 22, 29, 28, 33, 30, 33, 29, 36, 33, 34, 32, 28, 29, 31, 28, 34, 25, 22, 36, 29, 31, 28, 26, 27, 34, 29, 35, 31, 33, 32, 31, 26, 28, 29, 30, 35, 30, 28, 32, 33, 26, 35, 33, 33, 32, 31, 24, 23, 32, 28, 30, 29, 23, 29, 30, 29, 34, 30, 32, 30, 28, 23, 31, 26, 25, 33, 30, 28, 26, 28, 31, 24, 35, 33, 34, 24, 28, 31, 24, 30, 36, 35, 25, 29, 32, 30, 33, 29, 26, 29, 27, 29, 28, 35, 33, 37, 34, 35, 29, 25, 29, 26, 31, 30, 30, 29, 29, 31, 32, 29, 35, 30, 29, 30, 25, 33, 37, 30, 31, 31, 33, 25, 22, 27, 30, 26, 30, 31, 26, 35, 34, 28, 26, 24, 31, 34, 33, 28, 29, 30, 30, 34, 36, 31, 29, 23, 35, 27, 26, 25, 35, 32, 34, 33, 34, 33, 27, 23, 30, 25, 24, 27, 31, 25
$ cr <dbl> 12, 15, 13, 15, 11, 6, 15, 12, 14, 12, 9, 8, 10, 7, 11, 10, 13, 14, 7, 16, 14, 7, 8, 10, 8, 13, 13, 10, 13, 11, 8, 12, 16, 15, 8, 12, 13, 14, 6, 13, 9, 11, 13, 11, 14, 17, 9, 13, 12, 9, 13, 9, 9, 14, 15, 12, 13, 10, 7, 14, 15, 8, 11, 11, 7, 13, 14, 14, 12, 16, 14, 7, 11, 9, 16, 10, 7, 10, 10, 10, 7, 8, 13, 12, 14, 15, 8, 7, 13, 7, 9, 11, 12, 10, 18, 9, 6, 11, 9, 11, 14, 8, 10, 13, 13, 9, 15, 10, 16, 9, 12, 11, 14, 11, 15, 10, 12, 17, 12, 8, 16, 8, 6, 10, 11, 10, 13, 8, 12, 11, 12, 12, 11, 13, 9, 11, 9, 11, 13, 9, 12, 6, 11, 11, 8, 8, 8, 7, 6, 10, 15, 10, 11, 11, 10, 12, 14, 14, 13, 13, 11, 13, 7, 15, 11, 16, 12, 14, 13, 15, 16, 9, 9, 7, 16, 12, 9, 8, 14, 12, 13, 14, 10, 8, 8, 12, 12, 10, 7, 13, 11, 12, 12, 11, 12, 13, 15, 18, 12, 9, 13, 13, 16, 9, 7, 12, 10, 6, 13, 12, 15, 10, 11, 12, 16, 13, 10, 8, 9, 8, 15, 7, 15, 12, 14, 9, 13, 10, 15, 8, 10, 10, 9, 15, 12, 10, 15, 17, 11, 13, 10, 12, 12, 9, 13, 12, 12, 15, 7, 8, 6, 12, 12, 8, 13, 12, 8, 7, 12, 11, 10, …
$ df <dbl> 2315, 2304, 2646, 2281, 2789, 2719, 2233, 2667, 2527, 2574, 2360, 2380, 2535, 2482, 2485, 2302, 2370, 2316, 2506, 2230, 2432, 2481, 2737, 2612, 2382, 2774, 2415, 2447, 2241, 2595, 2537, 2718, 2413, 2526, 2450, 2727, 2583, 2557, 2229, 2436, 2440, 2262, 2449, 2789, 2439, 2536, 2452, 2713, 2262, 2388, 2529, 2528, 2781, 2328, 2498, 2500, 2802, 2549, 2386, 2169, 2818, 2402, 2282, 2436, 2546, 2524, 2204, 2519, 2524, 2423, 2425, 2310, 2308, 2634, 2265, 2443, 2484, 2728, 2267, 2584, 2183, 2858, 2437, 2526, 2423, 2185, 2540, 2586, 2727, 2832, 2729, 2725, 2748, 2504, 2523, 2579, 2597, 2475, 2159, 2737, 2392, 2383, 2705, 2434, 2674, 2672, 2603, 2776, 2611, 2588, 2575, 2890, 2667, 2614, 2434, 2434, 2423, 2396, 2422, 2638, 2744, 2249, 2451, 2631, 2444, 2133, 2443, 2624, 2639, 2670, 2571, 2771, 2685, 2589, 2773, 2573, 2863, 2816, 2588, 2515, 2569, 2575, 2600, 2224, 2610, 2621, 2176, 2615, 2149, 2144, 2569, 2610, 2423, 2669, 2669, 2616, 2960, 2412, 2454, 2641, 2684, 2456
$ ra <dbl> -10, -8, -12, -7, -8, -6, -12, -16, -12, -10, -12, -12, -6, -15, -12, -10, -12, -8, -14, -15, -12, -18, -14, -11, -13, -7, -6, -13, -8, -5, -12, -13, -14, -10, -21, -13, -7, -11, -16, -9, -11, -7, -8, -15, -13, -12, -11, -9, -12, -14, -6, -18, -14, -7, -15, -17, -10, -15, -13, -10, -12, -10, -7, -12, -12, -10, -10, -6, -11, -12, -13, -13, -7, -10, -15, -9, -9, -12, -10, -19, -12, -11, -18, -8, -11, -10, -9, -12, -16, -17, -6, -13, -10, -9, -13, -9, -14, -10, -11, -10, -12, -13, -14, -12, -11, -9, -16, -16, -11, -13, -13, -13, -6, -6, -14, -9, -14, -20, -14, -9, -10, -11, -8, -10, -15, -10, -15, -17, -12, -6, -10, -6, -5, -8, -11, -15, -10, -9, -8, -14, -14, -15, -13, -15, -9, -16, -8, -13, -10, -9, -11, -16, -14, -14, -12, -15, -14, -13, -13, -8, -11, -15, -11, -8, -11, -16, -16, -16, -14, -14, -12, -11, -12, -14, -12, -11, -9, -12, -13, -7, -8, -7, -13, -7, -13, -11, -11, -13, -17, -6, -14, -14, -8, -10, -11, -10, -8, -14, -9, -21, -12, -11, -11, -11, -12
$ pr <dbl> 46, 49, 43, 50, 57, 51, 46, 55, 56, 45, 47, 50, 57, 57, 52, 46, 51, 59, 44, 44, 42, 54, 46, 48, 51, 47, 48, 51, 47, 47, 49, 49, 55, 49, 44, 49, 57, 49, 48, 47, 48, 50, 54, 48, 51, 44, 53, 50, 47, 51, 53, 52, 46, 44, 50, 47, 47, 53, 47, 47, 46, 48, 52, 50, 51, 46, 52, 42, 51, 64, 48, 48, 52, 52, 54, 50, 47, 49, 48, 55, 52, 51, 50, 43, 44, 55, 47, 51, 51, 51, 42, 51, 54, 47, 46, 48, 52, 49, 48, 50, 46, 45, 45, 50, 51, 45, 55, 48, 45, 50, 46, 49, 47, 47, 49, 49, 53, 53, 49, 42, 51, 46, 47, 51, 50, 45, 46, 57, 58, 51, 47, 47, 45, 48, 46, 54, 48, 46, 45, 44, 56, 51, 44, 54, 45, 55, 49, 44, 53, 49, 48, 51, 46, 55, 42, 47, 47, 53, 53, 47, 46, 49, 44, 55, 46, 50, 58, 58, 61, 57, 56, 52, 50, 44, 45, 55, 47, 51, 52, 50, 53, 55, 50, 43, 55, 47, 48, 49, 49, 61, 50, 48, 50, 52, 47, 50, 49, 49, 44, 47, 51, 53, 53, 48, 49, 47, 46, 52, 45, 47, 55, 43, 49, 51, 54, 43, 51, 49, 50, 45, 50, 46, 51, 49, 47, 48, 46, 43, 44, 48, 48, 53, 48, 49, 58, 56, 42, 47, 57, 54, 52, 50, 45
$ standard1 <dbl> 47, 69, 139, 112, 101, 90, 79, 262, 123, 47, 95, 56, 41, 57, 144, 68, 62, 52, 101, 69, 134, 167, 51, 73, 89, 55, 74, 69, 117, 244, 208, 95, 62, 148, 96, 28, 101, 58, 73, 173, 84, 51, 95, 52, 74, 47, 68, 58, 47, 51, 96, 63, 102, 80, 62, 46, 87, 100, 111, 96, 177, 150, 172, 133, 68, 112, 112, 68, 90, 90, 113, 47, 50, 96, 80, 78, 29, 105, 42, 59, 91, 68, 53, 64, 83, 52, 117, 84, 57, 101, 51, 63, 41, 67, 53, 75, 53, 155, 79, 95, 120, 41, 150, 63, 130, 83, 118, 80, 96, 58, 70, 31, 65, 113, 58, 129, 69, 95, 69, 168, 171, 106, 136, 73, 79, 47, 52, 90, 50, 106, 57, 68, 154, 68, 53, 62, 89, 113, 58, 58, 53, 32, 47, 155, 62, 41, 79, 112, 88, 57, 96, 63, 72, 107, 79, 52, 26, 106, 34, 73, 41, 29, 58, 119, 51, 62, 35, 133, 139, 85, 57, 25, 69, 78, 56, 70, 112, 46, 62, 63, 63, 105, 52, 79, 162, 35, 90, 62, 43, 58, 133, 68, 35, 55, 13, 24, 41, 68, 46, 85, 57, 36, 41, 74, 59, 66, 118, 75, 36, 36, 90, 69, 62, 64, 53, 74, 74, 35, 38, 106, 107, 89, 25, 51, 61, 24, 102, 25, 6
$ standard2 <dbl> 46, 44, 102, 112, 101, 68, 41, 237, 106, 62, 117, 52, 51, 41, 128, 41, 68, 89, 80, 80, 112, 118, 52, 84, 106, 78, 77, 70, 73, 242, 102, 42, 46, 134, 57, 36, 52, 68, 63, 69, 90, 62, 95, 57, 107, 52, 60, 52, 40, 52, 99, 41, 129, 57, 52, 57, 82, 59, 101, 79, 156, 131, 107, 95, 100, 69, 125, 56, 215, 200, 127, 47, 97, 112, 38, 63, 48, 63, 41, 68, 101, 86, 47, 73, 57, 36, 106, 100, 57, 61, 70, 68, 52, 95, 47, 103, 79, 129, 128, 120, 41, 52, 90, 96, 100, 53, 64, 79, 85, 47, 81, 67, 75, 88, 85, 117, 80, 69, 63, 79, 188, 90, 129, 80, 47, 41, 49, 96, 58, 84, 36, 52, 161, 76, 32, 86, 68, 53, 268, 52, 92, 74, 57, 136, 41, 37, 41, 86, 57, 30, 123, 84, 90, 74, 52, 42, 57, 95, 52, 89, 45, 51, 68, 68, 63, 77, 106, 90, 91, 51, 34, 66, 73, 79, 73, 56, 74, 61, 35, 45, 57, 87, 57, 52, 90, 24, 57, 101, 41, 46, 83, 79, 35, 91, 16, 41, 85, 112, 265, 89, 40, 31, 72, 62, 52, 47, 46, 39, 63, 59, 74, 63, 52, 57, 46, 57, 84, 19, 46, 91, 46, 73, 69, 63, 78, 30, 69, 30, 47, 73, 104, 4
$ standard3 <dbl> 42, 36, 85, 117, 80, 73, 46, 166, 95, 63, 84, 41, 57, 30, 166, 52, 84, 63, 106, 57, 102, 123, 62, 136, 90, 63, 83, 95, 111, 85, 124, 45, 57, 112, 67, 39, 95, 62, 62, 38, 87, 50, 104, 69, 82, 69, 41, 52, 47, 41, 79, 24, 52, 62, 56, 98, 83, 62, 111, 68, 145, 134, 116, 117, 79, 79, 90, 57, 117, 89, 95, 48, 91, 80, 74, 59, 47, 151, 53, 155, 74, 91, 47, 62, 90, 55, 101, 86, 33, 69, 57, 84, 48, 90, 75, 86, 47, 139, 107, 112, 134, 80, 86, 97, 102, 39, 102, 53, 118, 62, 59, 64, 89, 102, 70, 90, 117, 63, 68, 56, 139, 101, 79, 80, 51, 35, 57, 68, 35, 95, 63, 52, 79, 53, 46, 61, 54, 53, 96, 53, 58, 90, 75, 96, 50, 74, 52, 89, 85, 53, 158, 89, 100, 52, 68, 45, 74, 255, 45, 62, 39, 47, 67, 30, 56, 78, 82, 172, 68, 55, 67, 56, 75, 49, 68, 73, 73, 63, 63, 79, 105, 53, 41, 101, 62, 25, 79, 89, 41, 45, 90, 64, 51, 51, 30, 46, 90, 47, 65, 107, 30, 41, 61, 84, 57, 46, 62, 112, 68, 41, 50, 57, 67, 52, 39, 73, 80, 34, 68, 102, 83, 78, 41, 37, 50, 41, 47, 25, 90, 30, 74, 44, 67
$ alternative1 <dbl> 28, 33, 227, 101, 126, 143, 50, 123, 76, 53, 121, 85, 63, 59, 125, 109, 60, 58, 184, 82, 79, 161, 55, 116, 122, 148, 75, 86, 69, 180, 145, 38, 97, 156, 85, 32, 74, 50, 80, 130, 93, 60, 120, 60, 79, 49, 87, 42, 48, 40, 98, 40, 120, 47, 33, 58, 87, 35, 127, 70, 149, 162, 113, 114, 81, 65, 98, 73, 93, 62, 118, 117, 79, 124, 52, 190, 91, 108, 75, 87, 93, 225, 38, 83, 40, 29, 131, 109, 28, 75, 49, 78, 74, 76, 53, 160, 85, 182, 100, 104, 45, 62, 147, 170, 103, 101, 103, 119, 114, 127, 78, 50, 123, 279, 47, 143, 52, 46, 59, 198, 61, 206, 283, 117, 33, 32, 50, 94, 47, 131, 91, 78, 159, 98, 43, 32, 76, 114, 99, 72, 38, 73, 72, 83, 47, 49, 48, 140, 163, 45, 45, 138, 137, 39, 77, 32, 29, 158, 37, 79, 27, 65, 145, 26, 51, 67, 128, 118, 56, 33, 36, 92, 107, 135, 35, 49, 111, 100, 46, 50, 45, 53, 45, 168, 86, 28, 68, 87, 68, 46, 103, 53, 38, 44, 33, 47, 61, 47, 113, 47, 126, 47, 67, 78, 115, 43, 63, 92, 52, 43, 68, 70, 76, 54, 44, 45, 80, 62, 44, 77, 28, 162, 40, 47, 19
$ alternative2 <dbl> 48, 27, 111, 81, 60, 103, 36, 122, 80, 48, 152, 45, 49, 63, 55, 62, 55, 58, 161, 49, 97, 118, 105, 91, 123, 171, 87, 129, 79, 187, 133, 62, 83, 109, 94, 38, 60, 50, 63, 54, 106, 59, 79, 66, 110, 51, 48, 46, 48, 66, 70, 53, 129, 50, 48, 37, 82, 50, 151, 50, 80, 222, 224, 93, 74, 79, 67, 162, 118, 62, 106, 34, 60, 141, 34, 101, 63, 63, 56, 68, 134, 41, 37, 82, 48, 31, 205, 153, 46, 92, 53, 73, 78, 51, 47, 86, 143, 156, 126, 87, 83, 40, 111, 80, 74, 84, 50, 67, 81, 60, 69, 35, 65, 91, 128, 76, 79, 27, 54, 229, 136, 145, 192, 129, 38, 45, 55, 137, 68, 136, 66, 59, 207, 73, 40, 44, 64, 66, 135, 66, 66, 132, 61, 159, 70, 41, 45, 193, 64, 46, 92, 69, 78, 82, 57, 48, 70, 182, 55, 88, 33, 36, 55, 53, 61, 45, 100, 88, 176, 39, 32, 73, 80, 110, 44, 55, 97, 82, 45, 48, 33, 49, 45, 93, 100, 42, 48, 99, 80, 59, 98, 60, 46, 55, 23, 36, 36, 39, 62, 80, 35, 40, 41, 86, 74, 53, 44, 224, 41, 68, 62, 57, 62, 53, 30, 32, 68, 46, 41, 84, 64, 109, 40, 44, 144, 21, 68, 57, 57, 49
$ alternative3 <dbl> 43, 37, 126, 61, 76, 113, 29, 188, 84, 57, 139, 63, 45, 67, 218, 45, 60, 63, 219, 66, 76, 144, 175, 75, 125, 136, 79, 93, 65, 213, 109, 58, 47, 85, 258, 53, 74, 63, 72, 172, 93, 47, 84, 66, 84, 48, 66, 38, 33, 73, 97, 26, 52, 51, 45, 50, 83, 44, 161, 50, 117, 168, 120, 109, 91, 60, 67, 89, 118, 37, 79, 57, 97, 92, 49, 77, 58, 68, 74, 82, 68, 47, 38, 62, 58, 36, 130, 120, 37, 84, 73, 120, 69, 81, 47, 101, 102, 87, 173, 136, 101, 101, 69, 84, 96, 80, 51, 105, 89, 61, 149, 56, 76, 99, 202, 104, 82, 40, 73, 68, 195, 109, 213, 146, 33, 45, 55, 84, 57, 125, 61, 64, 184, 87, 32, 48, 93, 57, 107, 61, 56, 114, 71, 127, 55, 49, 44, 240, 159, 58, 105, 87, 72, 37, 51, 49, 83, 120, 60, 68, 55, 47, 72, 28, 92, 51, 83, 96, 65, 44, 39, 72, 74, 56, 51, 57, 78, 83, 45, 78, 44, 58, 63, 93, 48, 47, 57, 87, 60, 55, 87, 72, 43, 76, 23, 28, 56, 47, 74, 94, 38, 36, 74, 99, 68, 84, 33, 102, 65, 48, 45, 87, 94, 47, 29, 60, 92, 32, 32, 91, 40, 83, 27, 43, 154, 39, 65, 57, 53, 75, 10
$ two_choice_latency <dbl> 134, 47, 273, 281, 110, 107, 187, 113, 70, 63, 117, 91, 150, 30, 276, 172, 83, 72, 178, 128, 127, 258, 52, 166, 205, 65, 88, 91, 120, 138, 169, 103, 168, 148, 71, 58, 90, 76, 90, 107, 126, 101, 132, 46, 102, 44, 48, 101, 76, 52, 61, 58, 112, 101, 89, 172, 84, 73, 123, 171, 112, 188, 166, 96, 93, 83, 161, 68, 139, 97, 128, 47, 166, 126, 91, 92, 116, 157, 79, 118, 106, 101, 37, 68, 78, 56, 186, 112, 78, 51, 45, 137, 59, 37, 58, 198, 69, 170, 210, 76, 86, 102, 140, 75, 199, 119, 85, 80, 90, 96, 149, 88, 166, 140, 259, 268, 223, 62, 68, 75, 111, 139, 243, 190, 96, 36, 78, 155, 46, 251, 95, 86, 258, 205, 36, 142, 117, 109, 296, 69, 141, 73, 123, 137, 68, 52, 129, 112, 107, 111, 174, 107, 142, 32, 112, 53, 58, 161, 78, 116, 46, 57, 139, 40, 75, 63, 159, 237, 85, 30, 63, 170, 167, 116, 61, 149, 90, 64, 111, 231, 126, 55, 219, 72, 52, 28, 71, 184, 41, 61, 123, 96, 106, 196, 232, 32, 45, 121, 77, 113, 167, 52, 48, 211, 41, 53, 128, 84, 50, 39, 193, 74, 167, 212, 59
$ two_choice <chr> "Standard", "Alternative", "Alternative", "Standard", "Alternative", "Standard", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Alternative", "Standard", "Standard", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Alternative", "Standard", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Alternative", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Alternative", "Standard", "Standard", "Standard", "Standard", "Standard", "Alternative", "Standard", "Standard", "Alternative", "Alternative", "Alternative", "Standard", "Alternative", "…
$ phonotaxis_score <dbl> 0.058823529, 0.219512195, -0.174242424, 0.169230769, 0.038674033, -0.218274112, 0.182795699, 0.213114754, 0.148936170, 0.036363636, -0.161016949, -0.122807018, -0.019607843, -0.188679245, 0.046594982, -0.142857143, 0.100775194, 0.062500000, -0.323943662, 0.022222222, 0.160000000, -0.018050542, -0.341317365, 0.020833333, -0.128440367, -0.400921659, -0.012658228, -0.138121547, 0.169590643, -0.007832898, 0.058394161, 0.070175439, -0.160305344, 0.056451613, -0.333333333, -0.093333333, 0.092105263, 0.076923077, -0.043478261, -0.122641509, -0.054347826, -0.009174312, 0.020833333, -0.040650407, -0.016759777, 0.066666667, -0.089430894, 0.125000000, 0.022727273, -0.111111111, 0.016759777, 0.036144578, -0.030927835, 0.147826087, 0.151515152, 0.165217391, 0.000000000, 0.264957265, -0.149606299, 0.173913043, 0.160583942, -0.142857143, -0.070422535, 0.045454545, 0.000000000, 0.122580645, 0.172043011, -0.285714286, 0.123505976, 0.400000000, 0.051643192, -0.189655172, 0.…
$ mismatch <dbl> 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, NA, 1, 0, 0, 1, 0, 0, 1, NA, 0, 1, 0, 0, 0, 0, 0, NA, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, NA, 0, 0, NA, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, NA, NA, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, NA, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, …
$ speaker_position <chr> "left", "left", "left", "left", "left", "left", "left", "left", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "left", "left", "left", "left", "left", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "right", "right", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "right", "right", "right", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "left", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "left", "left…
$ first_presented <chr> "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Alternative", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Alternative", "Alternative", "Alternative", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Alternative", "Standard", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Standard", "Alternative", "Alternative", "Standard", "Standard", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Alternative", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Standard", "Alternative", "Alternative", "Alternative", "Alternative", "Alternati…

Note janitor is not part of tidyverse but it's one of my favorites!

11/26

Quick skim of the data

skimr::skim(signal_cdat)
Skim summary statistics
n obs: 535
n variables: 18
── Variable type:character ──────────────────────────────────────
variable missing complete n min max empty n_unique
first_presented 0 535 535 8 11 0 2
speaker_position 161 374 535 4 5 0 2
two_choice 1 534 535 8 11 0 2
── Variable type:numeric ────────────────────────────────────────
variable missing complete n mean sd p0 p25 p50 p75 p100 hist
alternative1 0 535 535 83.77 43.91 20 52 76 101 295 ▆▇▅▂▁▁▁▁
alternative2 1 534 535 78.01 40.21 17 51 67 93 295 ▅▇▃▁▁▁▁▁
alternative3 2 533 535 78.23 38.19 23 54 72 91 294 ▅▇▃▁▁▁▁▁
cd 0 535 535 29.73 3.63 21 27 30 33 37 ▂▅▅▇▇▇▅▂
cr 0 535 535 11.36 2.74 6 9 11 13 19 ▃▅▃▇▆▂▂▁
df 0 535 535 2507.72 182.61 2040 2394 2527 2623.5 2960 ▁▃▃▅▇▅▂▁
frog_id 0 535 535 14456.81 520.19 13196 14204.5 14450 15031.5 15175 ▂▂▁▃▆▆▁▇
mismatch 11 524 535 0.37 0.48 0 0 0 1 1 ▇▁▁▁▁▁▁▅
phonotaxis_score 0 535 535 -0.01 0.15 -0.44 -0.11 -0.0065 0.099 0.4 ▁▁▅▇▇▆▂▁
pr 0 535 535 49.64 4.01 42 47 49 52 64 ▂▆▇▆▂▂▁▁
ra 0 535 535 -11.45 3.21 -22 -14 -11 -9 -5 ▁▁▂▅▇▇▆▃
standard1 0 535 535 80.74 36.79 13 57 73 96 291 ▂▇▅▁▁▁▁▁
standard2 0 535 535 74.98 34 16 52 69 89 268 ▃▇▅▁▁▁▁▁
standard3 2 533 535 74.58 31.78 24 53 68 89 259 ▅▇▅▁▁▁▁▁
two_choice_latency 1 534 535 114.19 56.77 28 71 107 142 297 ▅▇▇▃▃▂▁▁

Note skimr is not part of tidyverse but it's also one of my favorites!

12/26

Make new variables with dplyr::mutate

Aim: create a new variable of phonotaxis score


signal_cdat2 <- mutate(signal_cdat,
# rounding needed to get the same result as paper
xbara = round((alternative1 + alternative2 + alternative3) / 3),
xbars = round((standard1 + standard2 + standard3) / 3),
# defintion of phonotaxis score
score = (xbars - xbara) / (xbars + xbara))


Think mutate as in for biology when a string of DNA is modified by mutation 🧬

13/26

Select variables with dplyr::select


select(signal_cdat2,
# below is using tidyselect
c(starts_with("standard"), starts_with("alt"),
starts_with("xbar"), score, starts_with("pho")))
# A tibble: 535 x 10
standard1 standard2 standard3 alternative1 alternative2 alternative3 xbara xbars score phonotaxis_score
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 47 46 42 28 48 43 40 45 0.0588 0.0588
2 69 44 36 33 27 37 32 50 0.220 0.220
3 139 102 85 227 111 126 155 109 -0.174 -0.174
4 112 112 117 101 81 61 81 114 0.169 0.169
5 101 101 80 126 60 76 87 94 0.0387 0.0387
6 90 68 73 143 103 113 120 77 -0.218 -0.218
7 79 41 46 50 36 29 38 55 0.183 0.183
8 262 237 166 123 122 188 144 222 0.213 0.213
9 123 106 95 76 80 84 80 108 0.149 0.149
10 47 62 63 53 48 57 53 57 0.0364 0.0364
# … with 525 more rows
14/26

Subsetting data with dplyr::filter

signal_cdatm <- filter(signal_cdat2, is.na(speaker_position))
glimpse(select(signal_cdatm, speaker_position))
Observations: 161
Variables: 1
$ speaker_position <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA
  • Note: dplyr::filter conflicts with stats::filter
  • Usually loading tidyverse displays this conflict
tidyverse_conflicts()
── Conflicts ─────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
15/26

Summarising data with dplyr::summarise usually coupled with dplyr::group_by

signal_cdatg <- group_by(signal_cdatm, two_choice)
signal_cdats <- summarise(signal_cdatg,
avg_score = mean(score, na.rm = TRUE),
sd_score = sd(score, na.rm = TRUE),
nmissing = sum(is.na(score)),
n = n())
signal_cdats
# A tibble: 2 x 5
two_choice avg_score sd_score nmissing n
<chr> <dbl> <dbl> <int> <int>
1 Alternative 0.0407 0.122 0 60
2 Standard -0.0386 0.152 1 101
16/26

The full code to get to the table summary

signal_cdat <- janitor::clean_names(signal_dat)
signal_cdat2 <- mutate(signal_cdat,
xbara = round((alternative1 + alternative2 + alternative3) / 3),
xbars = round((standard1 + standard2 + standard3) / 3),
score = (xbars - xbara) / (xbars + xbara))
signal_cdatm <- filter(signal_cdat2, is.na(speaker_position))
signal_cdatg <- group_by(signal_cdatm, two_choice)
signal_cdats <- summarise(signal_cdatg,
avg_score = mean(score, na.rm = TRUE),
sd_score = sd(score, na.rm = TRUE),
nmissing = sum(is.na(score)),
n = n())
17/26

The full code to get to the table summary

signal_cdat <- janitor::clean_names(signal_dat)
signal_cdat2 <- mutate(signal_cdat,
xbara = round((alternative1 + alternative2 + alternative3) / 3),
xbars = round((standard1 + standard2 + standard3) / 3),
score = (xbars - xbara) / (xbars + xbara))
signal_cdatm <- filter(signal_cdat2, is.na(speaker_position))
signal_cdatg <- group_by(signal_cdatm, two_choice)
signal_cdats <- summarise(signal_cdatg,
avg_score = mean(score, na.rm = TRUE),
sd_score = sd(score, na.rm = TRUE),
nmissing = sum(is.na(score)),
n = n())

😩 The pain point - you have to think of a new variable name each time OR risk using the same and accidentally overwrite when unknowingly missed a sequence

17/26

The pipe operator from magrittr


%>%
<data> %>% <function>(<argA>, <argB>)
is the same as
<function>(<data>, <argA>, <argB>)

E.g. filter(signal_cdat2, is.na(speaker_position))
is the same as
signal_cdat2 %>% filter(is.na(speaker_position))
18/26

Chain of pipes

signal_dat %>%
janitor::clean_names() %>%
mutate(xbara = round((alternative1 + alternative2 + alternative3) / 3),
xbars = round((standard1 + standard2 + standard3) / 3),
score = (xbars - xbara) / (xbars + xbara)) %>%
filter(is.na(speaker_position)) %>%
group_by(two_choice) %>%
summarise(avg_score = mean(score, na.rm = TRUE),
sd_score = sd(score, na.rm = TRUE),
nmissing = sum(is.na(score)),
n = n())
# A tibble: 2 x 5
two_choice avg_score sd_score nmissing n
<chr> <dbl> <dbl> <int> <int>
1 Alternative 0.0407 0.122 0 60
2 Standard -0.0386 0.152 1 101
19/26

Main dplyr verbs

  • mutate() - create new or overwrite existing variables based on existing variables
  • select() - select and rename variables (reduces column)
  • filter() - subset data (reduces rows)
  • summarise() - reduce data to a summary statistics
  • arrange() - ???
  • group_by() coupled with ungroup() - group operations

What does arrange() do?

20/26

Special extensions
*_if(), *_at() and *_all()

mutate_if()
mutate_at()
mutate_all()

select_if()
select_at()
select_all()

filter_if()
filter_at()
filter_all()

summarise_if()
summarise_at()
summarise_all()

group_by_if()
group_by_at()
group_by_all()

arrange_if()
arrange_at()
arrange_all()

21/26

*_if()

signal_cdat %>%
mutate_if(is.character, as.factor) %>%
select_if(is.factor)
# A tibble: 535 x 3
two_choice speaker_position first_presented
<fct> <fct> <fct>
1 Standard left Alternative
2 Alternative left Alternative
3 Alternative left Alternative
4 Standard left Standard
5 Alternative left Standard
6 Standard left Standard
7 Alternative left Alternative
8 Alternative left Standard
9 Alternative right Standard
10 Standard right Standard
# … with 525 more rows
22/26

*_at()

scale2 <- function(x, na.rm = FALSE)
(x - mean(x, na.rm = na.rm)) / sd(x, na.rm)
signal_cdat2 %>%
mutate_at("score", scale2)

To use tidyselect, the variables need to be wrapped with vars() function:

signal_cdat2 %>%
mutate_at(vars(cd:pr), scale2)
23/26

*_all()

Applies function to all variables


signal_cdat2 %>%
mutate_all(I)
24/26

Open and go through:

challenge-04-wrangling.Rmd


For answers go to (but don't look until trying!):

challenge-04-wrangling-solution.Rmd

25/26

Session Information

devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.0 (2019-04-26)
os macOS Mojave 10.14.6
system x86_64, darwin15.6.0
ui X11
language (EN)
collate en_AU.UTF-8
ctype en_AU.UTF-8
tz Australia/Adelaide
date 2019-12-03
─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
anicon 0.1.0 2019-05-28 [1] Github (emitanaka/anicon@377aece)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
broom 0.5.2 2019-04-07 [1] CRAN (R 3.6.0)
callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.0)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.6.0)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
crosstalk 1.0.0 2016-12-21 [1] CRAN (R 3.6.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0)
devtools 2.0.2 2019-04-08 [1] CRAN (R 3.6.0)
digest 0.6.22 2019-10-21 [1] CRAN (R 3.6.0)
dplyr * 0.8.3 2019-07-04 [1] CRAN (R 3.6.0)
DT 0.6 2019-05-09 [1] CRAN (R 3.6.0)
emo 0.0.0.9000 2019-06-03 [1] Github (hadley/emo@02a5206)
evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.0)
forcats * 0.4.0 2019-02-17 [1] CRAN (R 3.6.0)
fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.0)
ggplot2 * 3.2.1 2019-08-10 [1] CRAN (R 3.6.0)
glue 1.3.1.9000 2019-10-24 [1] Github (tidyverse/glue@71eeddf)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)
haven 2.1.0 2019-02-19 [1] CRAN (R 3.6.0)
hms 0.5.1 2019-08-23 [1] CRAN (R 3.6.0)
htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.6.0)
httpuv 1.5.2 2019-09-11 [1] CRAN (R 3.6.0)
httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.0)
icon 0.1.0 2019-05-28 [1] Github (ropenscilabs/icon@a510f88)
janitor 1.2.0 2019-04-21 [1] CRAN (R 3.6.0)
jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0)
knitr 1.25 2019-09-18 [1] CRAN (R 3.6.0)
labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0)
later 1.0.0 2019-10-04 [1] CRAN (R 3.6.0)
lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0)
lifecycle 0.1.0 2019-08-01 [1] CRAN (R 3.6.0)
lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.6.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0)
mime 0.7 2019-06-11 [1] CRAN (R 3.6.0)
modelr 0.1.4 2019-02-18 [1] CRAN (R 3.6.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)
nlme 3.1-140 2019-05-12 [1] CRAN (R 3.6.0)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.0)
pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.6.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.0)
promises 1.1.0 2019-10-04 [1] CRAN (R 3.6.0)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0)
purrr * 0.3.2 2019-03-15 [1] CRAN (R 3.6.0)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0)
Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.0)
readr * 1.3.1 2018-12-21 [1] CRAN (R 3.6.0)
readxl 1.3.1 2019-03-13 [1] CRAN (R 3.6.0)
remotes 2.0.4 2019-04-10 [1] CRAN (R 3.6.0)
rlang 0.4.0.9000 2019-08-03 [1] Github (r-lib/rlang@b0905db)
rmarkdown 1.16 2019-10-01 [1] CRAN (R 3.6.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0)
rvest 0.3.4 2019-05-15 [1] CRAN (R 3.6.0)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
shiny 1.3.2 2019-04-22 [1] CRAN (R 3.6.0)
skimr 1.0.6 2019-05-27 [1] CRAN (R 3.6.0)
snakecase 0.10.0 2019-05-16 [1] CRAN (R 3.6.0)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
testthat 2.2.1 2019-07-25 [1] CRAN (R 3.6.0)
tibble * 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
tidyr * 1.0.0 2019-09-11 [1] CRAN (R 3.6.0)
tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.0)
tidyverse * 1.2.1 2017-11-14 [1] CRAN (R 3.6.0)
usethis 1.5.0 2019-04-07 [1] CRAN (R 3.6.0)
utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.0)
vctrs 0.2.0.9000 2019-08-03 [1] Github (r-lib/vctrs@11c34ae)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
xaringan 0.9 2019-03-06 [1] CRAN (R 3.6.0)
xfun 0.10 2019-10-01 [1] CRAN (R 3.6.0)
xml2 1.2.0 2018-01-24 [1] CRAN (R 3.6.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0)
yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.0)
[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

These slides are licensed under

26/26

Tidyverse Workshop



Data wrangling with dplyr & tidyr

Presented by Emi Tanaka

School of Mathematics and Statistics


dr.emi.tanaka@gmail.com @statsgen

1st Dec 2019 @ Biometrics by the Botanic Gardens | Adelaide, Australia

1/26
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow