# excel file
data <- read_excel("../00_data/myData_charts.xlsx", sheet = "myData", skip = 1)
## New names:
## • `` -> `...1`
data
## # A tibble: 195 × 18
## ...1 Breed Affec…¹ Good …² Good …³ Shedd…⁴ Coat …⁵ Drool…⁶ Coat …⁷ Coat …⁸
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 167 Plott … 0 0 0 0 0 0 Plott … Plott …
## 2 6 Poodles 5 5 3 1 NA 1 Curly Long
## 3 13 Yorksh… 5 5 3 1 5 1 Silky Long
## 4 20 Shih T… 5 5 5 1 4 1 Double Long
## 5 38 Maltese 5 3 3 1 4 1 Silky Long
## 6 45 Bichon… 5 5 5 1 5 1 Double Long
## 7 58 Soft C… 5 5 3 1 4 2 Wavy Medium
## 8 62 Aireda… 3 3 3 1 3 1 Wiry Short
## 9 78 Lhasa … 5 3 3 1 3 1 Silky Long
## 10 79 Chines… 4 3 3 1 2 1 Hairle… Short
## # … with 185 more rows, 8 more variables: `Openness To Strangers` <dbl>,
## # `Playfulness Level` <dbl>, `Watchdog/Protective Nature` <dbl>,
## # `Adaptability Level` <dbl>, `Trainability Level` <dbl>,
## # `Energy Level` <dbl>, `Barking Level` <dbl>,
## # `Mental Stimulation Needs` <dbl>, and abbreviated variable names
## # ¹`Affectionate With Family`, ²`Good With Young Children`,
## # ³`Good With Other Dogs`, ⁴`Shedding Level`, ⁵`Coat Grooming Frequency`, …
data <- data %>%
janitor::clean_names()
filter(data, shedding_level == 2, coat_grooming_frequency == 3)
## # A tibble: 9 × 18
## x1 breed affec…¹ good_…² good_…³ shedd…⁴ coat_…⁵ drool…⁶ coat_…⁷ coat_…⁸
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 23 Pomeran… 5 3 3 2 3 1 Double Long
## 2 24 Havanese 5 5 5 2 3 1 Double Long
## 3 36 Basset … 3 5 5 2 3 4 Smooth Short
## 4 57 Scottis… 5 3 2 2 3 2 Wiry Medium
## 5 104 Fox Ter… 5 5 3 2 3 2 Wiry Medium
## 6 108 Silky T… 5 3 3 2 3 1 Silky Long
## 7 112 Welsh T… 5 5 3 2 3 2 Wiry Medium
## 8 169 Glen of… 5 3 3 2 3 2 Wiry Medium
## 9 181 Dandie … 4 3 3 2 3 1 Double Medium
## # … with 8 more variables: openness_to_strangers <dbl>,
## # playfulness_level <dbl>, watchdog_protective_nature <dbl>,
## # adaptability_level <dbl>, trainability_level <dbl>, energy_level <dbl>,
## # barking_level <dbl>, mental_stimulation_needs <dbl>, and abbreviated
## # variable names ¹affectionate_with_family, ²good_with_young_children,
## # ³good_with_other_dogs, ⁴shedding_level, ⁵coat_grooming_frequency,
## # ⁶drooling_level, ⁷coat_type, ⁸coat_length
arrange(data, desc(shedding_level))
## # A tibble: 195 × 18
## x1 breed affec…¹ good_…² good_…³ shedd…⁴ coat_…⁵ drool…⁶ coat_…⁷ coat_…⁸
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 22 Bernes… 5 5 5 5 3 3 Double Medium
## 2 1 Retrie… 5 5 5 4 2 2 Double Short
## 3 3 German… 5 5 3 4 2 2 Double Medium
## 4 4 Retrie… 5 5 5 4 2 2 Double Medium
## 5 11 Pembro… 5 3 4 4 2 1 Double Short
## 6 16 Siberi… 5 5 5 4 2 1 Double Medium
## 7 18 Doberm… 5 5 3 4 1 2 Smooth Short
## 8 29 Pugs 5 5 4 4 2 1 Smooth Short
## 9 51 Dalmat… 5 3 3 4 2 2 Smooth Short
## 10 71 Dogues… 5 3 3 4 1 5 Smooth Short
## # … with 185 more rows, 8 more variables: openness_to_strangers <dbl>,
## # playfulness_level <dbl>, watchdog_protective_nature <dbl>,
## # adaptability_level <dbl>, trainability_level <dbl>, energy_level <dbl>,
## # barking_level <dbl>, mental_stimulation_needs <dbl>, and abbreviated
## # variable names ¹affectionate_with_family, ²good_with_young_children,
## # ³good_with_other_dogs, ⁴shedding_level, ⁵coat_grooming_frequency,
## # ⁶drooling_level, ⁷coat_type, ⁸coat_length
select(data, shedding_level, coat_length, coat_type)
## # A tibble: 195 × 3
## shedding_level coat_length coat_type
## <dbl> <chr> <chr>
## 1 0 Plott Hounds Plott Hounds
## 2 1 Long Curly
## 3 1 Long Silky
## 4 1 Long Double
## 5 1 Long Silky
## 6 1 Long Double
## 7 1 Medium Wavy
## 8 1 Short Wiry
## 9 1 Long Silky
## 10 1 Short Hairless
## # … with 185 more rows
mutate(data,
gain = energy_level - trainability_level)
## # A tibble: 195 × 19
## x1 breed affec…¹ good_…² good_…³ shedd…⁴ coat_…⁵ drool…⁶ coat_…⁷ coat_…⁸
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 167 Plott … 0 0 0 0 0 0 Plott … Plott …
## 2 6 Poodles 5 5 3 1 NA 1 Curly Long
## 3 13 Yorksh… 5 5 3 1 5 1 Silky Long
## 4 20 Shih T… 5 5 5 1 4 1 Double Long
## 5 38 Maltese 5 3 3 1 4 1 Silky Long
## 6 45 Bichon… 5 5 5 1 5 1 Double Long
## 7 58 Soft C… 5 5 3 1 4 2 Wavy Medium
## 8 62 Aireda… 3 3 3 1 3 1 Wiry Short
## 9 78 Lhasa … 5 3 3 1 3 1 Silky Long
## 10 79 Chines… 4 3 3 1 2 1 Hairle… Short
## # … with 185 more rows, 9 more variables: openness_to_strangers <dbl>,
## # playfulness_level <dbl>, watchdog_protective_nature <dbl>,
## # adaptability_level <dbl>, trainability_level <dbl>, energy_level <dbl>,
## # barking_level <dbl>, mental_stimulation_needs <dbl>, gain <dbl>, and
## # abbreviated variable names ¹affectionate_with_family,
## # ²good_with_young_children, ³good_with_other_dogs, ⁴shedding_level,
## # ⁵coat_grooming_frequency, ⁶drooling_level, ⁷coat_type, ⁸coat_length
#Summarize by rows
data %>%
# Group by shedding level
group_by(breed) %>%
summarize(shedding_level = mean(shedding_level, na.rm = TRUE)) %>%
# Sort it
arrange(shedding_level)
## # A tibble: 195 × 2
## breed shedding_level
## <chr> <dbl>
## 1 Plott Hounds 0
## 2 Afghan Hounds 1
## 3 Airedale Terriers 1
## 4 American Hairless Terriers 1
## 5 Australian Terriers 1
## 6 Barbets 1
## 7 Bedlington Terriers 1
## 8 Bergamasco Sheepdogs 1
## 9 Bichons Frises 1
## 10 Briards 1
## # … with 185 more rows