Part 1:

The map represents the percentage of households occupied in Davidson County as well as surrounding counties. The highest percentage of rentals occupied is Davidson County with a percentage of 45.8%. The lowest percent of rentals occupied is in Cheatham County with a percentage of 18.8%.

if (!require("tidyverse")) install.packages("tidyverse")
## Loading required package: tidyverse
## Warning: package 'tidyverse' was built under R version 4.3.3
## ── 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.4.4     ✔ 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
if (!require("tidycensus")) install.packages("tidycensus")
## Loading required package: tidycensus
if (!require("sf")) install.packages("sf")
## Loading required package: sf
## Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
if (!require("mapview")) install.packages("mapview")
## Loading required package: mapview
## Warning: package 'mapview' was built under R version 4.3.3
library(tidyverse)
library(tidycensus)
library(sf)
library(mapview)

census_api_key("df0faecd0926862cb1236c2095af91dbdec0b3da")
## To install your API key for use in future sessions, run this function with `install = TRUE`.
DetailedTables <- load_variables(2022, "acs5", cache = TRUE)
SubjectTables <- load_variables(2022, "acs5/subject", cache = TRUE)
ProfileTables <- load_variables(2022, "acs5/profile", cache = TRUE)

ChosenVars <- filter(ProfileTables,name == "DP04_0047P"|
                       name == "DP02_0001")

print(ChosenVars$name)
## [1] "DP02_0001"  "DP04_0047P"
print(ChosenVars$label)
## [1] "Estimate!!HOUSEHOLDS BY TYPE!!Total households"                  
## [2] "Percent!!HOUSING TENURE!!Occupied housing units!!Renter-occupied"
print(ChosenVars$concept)
## [1] "Selected Social Characteristics in the United States"
## [2] "Selected Housing Characteristics"
VariableList = 
  c(Rentals_ = "DP04_0047P",
    Households_ = "DP02_0001")

mydata <- get_acs(
  geography = "county",
  state = "TN",
  variables = VariableList,
  year = 2022,
  survey = "acs5",
  output = "wide",
  geometry = TRUE)
## Getting data from the 2018-2022 5-year ACS
## Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
## Using the ACS Data Profile
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  96%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
mydata <-
  separate_wider_delim(mydata,
                       NAME,
                       delim = ", ",
                       names = c("County", "State"))

filtereddata <- mydata %>% 
  filter(County == "Davidson County"|
           County == "Rutherford County"|
           County == "Williamson County"|
           County == "Cheatham County"|
           County == "Robertson County"|
           County == "Sumner County"|
           County == "Wilson County")

ggplot(filtereddata, aes(x = Rentals_E, y = reorder(County, Rentals_E))) + 
  geom_errorbarh(aes(xmin = Rentals_E - Rentals_M, xmax = Rentals_E + Rentals_M)) + 
  geom_point(size = 3, color = "darkblue") + 
  theme_minimal(base_size = 12.5) + 
  labs(title = "Pct. households with rentals", 
       subtitle = "Nashville-area counties. Brackets show error margins.", 
       x = "2018-2022 ACS estimate", 
       y = "")

mapdata <- filtereddata %>% 
  rename(Rentals = Rentals_E,
         Households = Households_E)

mapdata <- st_as_sf(mapdata)

mapviewOptions(basemaps.color.shuffle = FALSE)
mapview(mapdata, zcol = "Rentals",
        layer.name = "Pct. with rentals",
        popup = TRUE)
CSVdata <- st_drop_geometry(mapdata)
write.csv(CSVdata, "mydata.csv", row.names = FALSE)

Part 2:

Each chart shows a representation of the differences between photo, text, and video. The comparison between video and text had a significant difference because it was under 0.05. On the other hand, video and photo stayed close to comparison. Lastly, text and photo had a difference but it wasn’t as significant. After analyzing the results, the videographer does help improve social media engagement.

```{r}if (!require(“tidyverse”))} install.packages(“tidyverse”) library(tidyverse)

mydata <- read.csv(“https://raw.githubusercontent.com/drkblake/Data/main/SocialData.csv”)

mydata\(DV <- mydata\)Impressions mydata\(IV <- mydata\)Type

averages <- group_by(mydata, IV) %>% summarise(mean = mean(DV, na.rm = TRUE)) ggplot(mydata, aes(x = DV)) + geom_histogram() + facet_grid(IV ~ .) + geom_histogram(color = “black”, fill = “#1f78b4”) + geom_vline(data = averages, aes(xintercept = mean, ))

group_by(mydata, IV) %>% summarise( count = n(), mean = mean(DV, na.rm = TRUE), sd = sd(DV, na.rm = TRUE), min = min(DV, na.rm = TRUE), max = max(DV, na.rm = TRUE))

options(scipen = 999) oneway.test(mydata\(DV ~ mydata\)IV, var.equal = FALSE)

anova_1 <- aov(mydata\(DV ~ mydata\)IV) TukeyHSD(anova_1)


### Part 3:

The search terms I chose were election, POTUS, Harris, and vote. I found these terms to be trending and to have a distinct connection due to the upcoming election in November. The overall sum of all terms was 1,218 out of the 5,508 posts on X.


```r
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("tidytext")) install.packages("tidytext")
## Loading required package: tidytext
## Warning: package 'tidytext' was built under R version 4.3.3
library(tidyverse)
library(tidytext)

mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/WhiteHouse.csv")

tidy_text <- mydata %>% 
  unnest_tokens(word,Full.Text) %>% 
  count(word, sort = TRUE)

data("stop_words")
tidy_text <- tidy_text %>%
  anti_join(stop_words)
## Joining with `by = join_by(word)`
my_stopwords <- tibble(word = c("https",
                                "t.co",
                                "rt"))
tidy_text <- tidy_text %>% 
  anti_join(my_stopwords)
## Joining with `by = join_by(word)`
searchterms <- "Election|POTUS|Harris|Vote"
mydata$Biden <- ifelse(grepl(searchterms,
                             mydata$Full.Text,
                             ignore.case = TRUE),1,0)
sum(mydata$Biden)
## [1] 1218