Assignment 6

Swimcloud Commitment Posts

Is there a correlation between the power index or speed of a swimmer on swimcloud and the number of words that are in there commitment post. In other words, do swimmers with a lower power index meaning they are a better recruit post more words or vice versa. I find this interesting because I found the recruiting process very fun and I am interested to see what types of swimmers post more words.

I will answer this question by scraping data from swimcloud.com I will scrape the power index of each swimmer which is a number from 1 to 100 and there text in there commitment post. I will also scrape some other information about them such as there class rank state rank and the college they are going to. I will use this data to answer my question from above.

library(tidyverse) #For working with data
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── 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
#Importing the scraped data
swimData <- read_csv("https://myxavier-my.sharepoint.com/:x:/g/personal/leamera_xavier_edu/Eao3XW8lV0xLkRiBp0n40NgBxR19Cidll5-4vyrdYRx9fQ?download=1")
Rows: 100 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): posttext
dbl (1): powerindexrankings

ℹ 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.
#Creating a word count variable to analyze the correlation
#Then changing the na values to be 0 in the word count variable
swimData <- swimData %>% 
  mutate(word_count = str_count(posttext, "\\w+")) %>% 
  mutate(word_count = ifelse(is.na(word_count), 0, word_count))
#plot of power index score and word count seemingly very little correlation
swimData %>% 
  ggplot(aes(powerindexrankings,word_count))+
  geom_point()+
  geom_smooth(method = lm)
`geom_smooth()` using formula = 'y ~ x'

#decided to make another chart but with 0 word count observations filtered out
#to determine if there is a correlation there.

swimData %>% 
  filter(word_count > 0) %>% 
  ggplot(aes(powerindexrankings,word_count))+
  geom_point()+
  geom_smooth(method = lm)
`geom_smooth()` using formula = 'y ~ x'

#Don't see a correlation here at all

#conclusion:
#There does not seem to be a correlation at all between the power index of a 
#swimmer and how many words are in there commitment post. This essentially means
#that swimmers of all speeds write similar amounts of words for their posts.