library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
#Question One: Select some variables of interest and see if there is any obvious correlations using the COR command. Answer One: The correlation between adoptions and fosters is 38%. The correlation between adoptions and adoptions is 1 or 100% because it's the same thing as mentioned in the lecture.#
library(readxl)
dog_and_cat_data_<- read_excel("dog and cat data .xlsx")
shelter_sample<-dog_and_cat_data_ %>% select(Adoptions,Fosters) %>% arrange(-Adoptions,Fosters)
shelter_sample
## # A tibble: 8 × 2
## Adoptions Fosters
## <dbl> <dbl>
## 1 4682 631
## 2 3809 370
## 3 3737 1376
## 4 3358 773
## 5 1586 741
## 6 1354 422
## 7 1213 473
## 8 1135 460
cor(shelter_sample)
## Adoptions Fosters
## Adoptions 1.0000000 0.3837048
## Fosters 0.3837048 1.0000000
#Question Two: Examine the same variables visually using the PAIRS command Answer Two:
matrix_shelter <-cor(shelter_sample)
view(matrix_shelter)
pairs(~Adoptions+Fosters, matrix_shelter)

#Question Three: Select two variables that seem correlated (positively or negatively) and examine them using PEARSON, SPEARMAN or KENDALL (depending on which is more appropriate) Answer Three: I used the Kendall Correlation because I am working with a small data set and I was not assuming that there would be a strong correlation. An output of 0.2142857 indicates a weak relationship between the two variables#
x<- c(shelter_sample$Adoptions)
y<- c(shelter_sample$Fosters)
cor(x, y, method = "kendall")
## [1] 0.2142857