Import data
cats <- read_csv("../00_data/MKmyData1.csv")
## Rows: 101 Columns: 17
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (8): id.on.tag, animal.name, scientific.name, tag.deployment.start, tag....
## dbl (5): Column1, prey.per.month, hours.indoor.per.day, cats.in.house, age
## lgl (4): hunt, dry.food, wet.food, other.food
##
## ℹ 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.
cats
## # A tibble: 101 × 17
## Column1 id.on.tag animal.name scientific.name tag.deployment.start
## <dbl> <chr> <chr> <chr> <chr>
## 1 1 Tommy-Tag Tommy Felis catus 6/3/17 1:02
## 2 2 Athena Athena Felis catus 6/24/17 1:02
## 3 3 Ares Ares Felis catus 6/24/17 1:03
## 4 4 Lola Lola Felis catus 6/24/17 1:18
## 5 5 Maverick Maverick Felis catus 6/25/17 1:04
## 6 6 Coco Coco Felis catus 6/28/17 1:02
## 7 7 Charlie Charlie Felis catus 6/28/17 1:03
## 8 8 Jago Jago Felis catus 6/28/17 4:10
## 9 9 Morpheus-Tag Morpheus Felis catus 7/1/17 1:02
## 10 10 Nettle-Tag Nettle Felis catus 7/1/17 1:05
## # ℹ 91 more rows
## # ℹ 12 more variables: tag.deployment.end <chr>, hunt <lgl>,
## # prey.per.month <dbl>, reproductive.condition <chr>, sex <chr>,
## # hours.indoor.per.day <dbl>, cats.in.house <dbl>, dry.food <lgl>,
## # wet.food <lgl>, other.food <lgl>, study.location <chr>, age <dbl>
Introduction
Variation
Visualizing distributions
ggplot(data = cats) +
geom_bar(mapping = aes(x = reproductive.condition))

cats %>% count(reproductive.condition)
## # A tibble: 4 × 2
## reproductive.condition n
## <chr> <int>
## 1 Neutered 55
## 2 Not fixed 2
## 3 Spayed 41
## 4 <NA> 3
ggplot(data = cats) +
geom_histogram(mapping = aes(x = age))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (`stat_bin()`).

ggplot(data = cats, mapping = aes(x = age, colour = reproductive.condition)) +
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (`stat_bin()`).

Typical values
ggplot(data = cats, mapping = aes(x = cats.in.house)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Unusual values
ggplot(cats) +
geom_histogram(mapping = aes(x = prey.per.month), binwidth = 6)

Missing Values
cats2 <- cats %>%
mutate(y = ifelse(age < 3 | age > 15, NA, age))
ggplot(data = cats2, mapping = aes(x = age, y = reproductive.condition)) +
geom_point(na.rm = TRUE)

Covariation
A categorical and continuous variable
ggplot(data = cats, mapping = aes(x = age)) +
geom_freqpoly(mapping = aes(colour = reproductive.condition), binwidth = 0.75)
## Warning: Removed 1 rows containing non-finite values (`stat_bin()`).

ggplot(cats) +
geom_bar(mapping = aes(x = reproductive.condition))

ggplot(data = cats, mapping = aes(x = reproductive.condition, y = age)) +
geom_boxplot()
## Warning: Removed 1 rows containing non-finite values (`stat_boxplot()`).

Two categorical variables
ggplot(data = cats) +
geom_count(mapping = aes(x = reproductive.condition, y = sex))

cats %>%
count(reproductive.condition, sex) %>%
ggplot(mapping = aes(x = reproductive.condition, y = sex)) +
geom_tile(mapping = aes(fill = n))

Two continous variables
ggplot(data = cats) +
geom_point(mapping = aes(x = age, y = prey.per.month))
## Warning: Removed 1 rows containing missing values (`geom_point()`).

ggplot(data = cats) +
geom_point(mapping = aes(x = age, y = prey.per.month), alpha = 1/5)
## Warning: Removed 1 rows containing missing values (`geom_point()`).

ggplot(data = cats) +
geom_bin2d(mapping = aes(x = age, y = prey.per.month))
## Warning: Removed 1 rows containing non-finite values (`stat_bin2d()`).

ggplot(data = cats) +
geom_hex(mapping = aes(x = age, y = prey.per.month))
## Warning: Removed 1 rows containing non-finite values (`stat_binhex()`).

ggplot(data = cats, mapping = aes(x = age, y = prey.per.month)) +
geom_boxplot(mapping = aes(group = cut_width(age, 0.1)))
## Warning: Removed 1 rows containing missing values (`stat_boxplot()`).

Patterns and models
ggplot(data = cats) +
geom_point(mapping = aes(x = age, y = hours.indoor.per.day))
## Warning: Removed 1 rows containing missing values (`geom_point()`).

There is no true patterns or relationships with the numerical
variables