Part:1- Davidson County showed to have the highest amount of renter-occupied households on the map. Rutherford County had the second highest amount with 34.8 percent. All other counties had at least 20 percent or under.
```{r}if (!require(“tidyverse”)) install.packages(“tidyverse”)} if (!require(“tidycensus”)) install.packages(“tidycensus”) if (!require(“sf”)) install.packages(“sf”) if (!require(“mapview”)) install.packages(“mapview”)
library(tidyverse) library(tidycensus) library(sf) library(mapview)
census_api_key(“4ed7968903abe3ded81b469e74ccc6bcd8cb1e24”)
DetailedTables <- load_variables(2022, “acs5”, cache = TRUE) SubjectTables <- load_variables(2022, “acs5/subject”, cache = TRUE) ProfileTables <- load_variables(2022, “acs5/profile”, cache = TRUE) All_ACS_Variables <- bind_rows(DetailedTables, ProfileTables) All_ACS_Variables <- bind_rows (All_ACS_Variables, SubjectTables) rm (DetailedTables, SubjectTables,ProfileTables)
Variablelist = c(Estimate_ = “DP04_0047P”)
mydata <- get_acs( geography = “county”, state = “TN”, variables = Variablelist, year = 2022, survey = “acs5”, output = “wide”, geometry = TRUE)
mydata <- separate_wider_delim(mydata, NAME, delim = “,”, names = c(“County”, “State”)) mydata <- mydata %>% filter(County == “Cheatham County”| County == “Davidson County”| County == “Robertson County”| County == “Rutherford County”| County == “Sumner County”| County == “Williamson County”| County == “Wilson County”)
mapdata <- mydata %>% rename(Estimate = Estimate_E, Estimate_MOE = Estimate_M)
mapdata <- st_as_sf(mapdata)
mapviewOptions(basemaps.color.shuffle = FALSE) mapview(mapdata, zcol = “Estimate”, layer.name = “Estimate”, popup = TRUE)
CSVdata <- st_drop_geometry(mapdata) write.csv(CSVdata, “mydata.csv”, row.names = FALSE)
Part 2: Text is the lowest amounts of viewers. Video has a higher amount of viewers than both photo and text.
```r
if (!require("tidyverse"))
install.packages("tidyverse")
## Loading required package: 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.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
library(tidyverse)
mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/SocialData.csv")
head(mydata, 10)
## ID Type Impressions
## 1 1 Photo 695
## 2 2 Text 940
## 3 3 Photo 1196
## 4 4 Photo 936
## 5 5 Photo 1389
## 6 6 Photo 857
## 7 7 Text 797
## 8 8 Photo 1810
## 9 9 Photo 1086
## 10 10 Video 1416
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, ))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
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))
## # A tibble: 3 × 6
## IV count mean sd min max
## <chr> <int> <dbl> <dbl> <int> <int>
## 1 Photo 58 1035. 297. 397 1810
## 2 Text 43 999. 278. 515 1746
## 3 Video 39 1370. 307. 829 1952
options(scipen = 999)
oneway.test(mydata$DV ~ mydata$IV,
var.equal = FALSE)
##
## One-way analysis of means (not assuming equal variances)
##
## data: mydata$DV and mydata$IV
## F = 19.119, num df = 2.000, denom df = 85.525, p-value = 0.000000137
anova_1 <- aov(mydata$DV ~ mydata$IV)
TukeyHSD(anova_1)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = mydata$DV ~ mydata$IV)
##
## $`mydata$IV`
## diff lwr upr p adj
## Text-Photo -36.35605 -176.6202 103.9081 0.8126345
## Video-Photo 334.87710 190.5414 479.2128 0.0000005
## Video-Text 371.23315 217.1076 525.3587 0.0000002
Part 3: The theme I detected was jobs. It was an often mentioned term.
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("tidytext")) install.packages("tidytext")
## Loading required package: tidytext
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)`