We just went over the theory from Max McCombs and Dun Shaw that the media sets the agenda for the public, and in turn, the media tells viewers, listeners and readers what to focus on in daily life. So I wanted to think about when looking at the data between Fox News and CNN viewers on the topic of immigration. Did the media set anything by conservative or liberal standards, as both networks are known to have a bias among the left and the right, according to the bias chart from Poynter — a nonprofit journalism media studies institution.
Because of the current president’s view on immigration and Fox News leaning hard to the right, my hypothesis is that Fox News viewers will care more about the topic of immigration than regular watchers of CNN.
Six hundred viewers were asked about their watching habits and if they considered immigration a top issue or not a top issue.
That was 300 CNN viewers and 300 Fox News viewers. The dependent variable of the chi-square test performed was the issue of immigration while the independent variable was the news source.
Crosstabulation of DV by IV | ||
Counts and (Column Percentages) | ||
CNN | Fox | |
---|---|---|
1 Top issue | 35 (11.7%) | 115 (38.3%) |
2 Not top issue | 265 (88.3%) | 185 (61.7%) |
Chi-squared Test Results | |||
Test of Independence between DV and IV | |||
Test | Chi-squared Statistic | Degrees of Freedom | p-value |
---|---|---|---|
Chi-squared Test of Independence | 55.476 | 1 | 0.000 |
In conclusion, 38.3% of Fox viewers found immigration to be a top issue over the 11.7% of CNN viewers.
Likewise, 88.3% of CNN viewers said immigration wasn’t a top issues while only 61.7% of Fox viewers thought that way.
It seems that because of the nature of the news cycle, the presidency, and how the issue of immigration is framed on Fox and CNN, the hypothesis is founded.
Here is the code if you’re wanting to run your own table:
# ------------------------------
# Setup: Install and load packages
# ------------------------------
if (!require("tidyverse")) install.packages("tidyverse") # Data wrangling & plotting
if (!require("gmodels")) install.packages("gmodels") # Crosstabs
if (!require("gt")) install.packages("gt") # Table formatting
library(tidyverse)
library(gmodels)
library(gt)
# ------------------------------
# Load the data
# ------------------------------
# Replace "YOURFILENAME.csv" with your dataset name
mydata <- read.csv("TopIssue.csv") #Edit
# ------------------------------
# Define Dependent (DV) and Independent (IV) variables
# ------------------------------
# Replace YOURDVNAME and YOURIVNAME with actual column names in your data
mydata$DV <- mydata$Immigration #Edit
mydata$IV <- mydata$PreferredNetwork #Edit
# ------------------------------
# Visualization: Stacked bar chart of IV by DV
# ------------------------------
graph <- ggplot(mydata, aes(x = IV, fill = DV)) +
geom_bar(colour = "black") +
scale_fill_brewer(palette = "Paired") +
labs(
title = "Distribution of DV by IV",
x = "Independent Variable",
y = "Count",
fill = "Dependent Variable"
)
#Show the graph
graph
# ------------------------------
# Crosstabulation of DV by IV (DV = rows, IV = columns)
# ------------------------------
crosstab <- mydata %>%
count(DV, IV) %>%
group_by(IV) %>%
mutate(RowPct = 100 * n / sum(n)) %>%
ungroup() %>%
mutate(Cell = paste0(n, "\n(", round(RowPct, 1), "%)")) %>%
select(DV, IV, Cell) %>%
pivot_wider(names_from = IV, values_from = Cell)
# Format into gt table
crosstab_table <- crosstab %>%
gt(rowname_col = "DV") %>%
tab_header(
title = "Crosstabulation of DV by IV",
subtitle = "Counts and (Column Percentages)"
) %>%
cols_label(
DV = "Dependent Variable"
)
# Show the polished crosstab table
crosstab_table
# ------------------------------
# Chi-squared test of independence
# ------------------------------
options(scipen = 999) # Prevents scientific notation
chitestresults <- chisq.test(mydata$DV, mydata$IV)
# ------------------------------
# Format Chi-squared test results into a table
# ------------------------------
chitest_summary <- tibble(
Test = "Chi-squared Test of Independence",
Chi_sq = chitestresults$statistic,
df = chitestresults$parameter,
p = chitestresults$p.value
)
chitest_table <- chitest_summary %>%
gt() %>%
# Round χ² and p-value to 3 decimals, df to integer
fmt_number(columns = c(Chi_sq, p), decimals = 3) %>%
fmt_number(columns = df, decimals = 0) %>%
tab_header(
title = "Chi-squared Test Results",
subtitle = "Test of Independence between DV and IV"
) %>%
cols_label(
Test = "Test",
Chi_sq = "Chi-squared Statistic",
df = "Degrees of Freedom",
p = "p-value"
)
# Show the formatted results table
chitest_table