-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcleaning_penguins_data.R
37 lines (31 loc) · 1.7 KB
/
cleaning_penguins_data.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
# Code for cleaning the penguin data
# Data downloaded from https://dasl.datadescription.com/datafile/penguins/?_sfm_methods=Regression&_sfm_cases=4+59943&sf_paged=9
# Information from webpage where the data is from:
# Source: Jessica Meir personal communication
# Number of Cases: 125
# Story:
# Emperor penguins are the most accomplished divers among birds, making routine
# dives of 5–12 minutes, with the longest recorded dive over 27 minutes. These
# birds can also dive to depths of over 500 meters! Since air-breathing animals like
# penguins must hold their breath while submerged, the duration of any given dive
# depends on how much oxygen is in the bird’s body at the beginning of the dive, how
# quickly that oxygen gets used, and the lowest level of oxygen the bird can tolerate.
# The rate of oxygen depletion is primarily determined by the penguin’s heart rate.
# Consequently, studies of heart rates during dives can help us understand how these
# animals regulate their oxygen consumption in order to make such impressive dives.The researchers equipped emperor penguins with devices that record their heart rates during
# dives. The dataset reports Dive Heart Rate (beats per minute), the Duration
# (minutes) of dives, and other related variables.
# Load libraries
library(dplyr)
# Read in the penguin data
penguins_raw <- read.delim("./data-raw/penguins.txt")
# Clean the penguin data
penguins <- penguins_raw %>%
rename(heartrate = Dive.Heart.Rate,
depth = Depth.m.,
duration = Duration.min.,
bird = Bird.) %>%
mutate(bird = as.factor(as.numeric(bird))) %>%
arrange(bird)
# Add the cleaned penguins data to the data folder
devtools::use_data(penguins, overwrite = TRUE)