#HW 1A 1a) setwd(“~/Desktop/Econ 124/Data”) news <- read.csv(‘fakenews.csv’) survey <- read.csv(‘survey.csv’)

#1b) #The population of people would be Americans who are 18+, responded to the online survey and they answered questions about politics, media, and election news #It is not random because, they were recruited through an online survey rather than on street in person interviews. #People in this sample are more intune with the internet and online media coverage, along with being more politically engaged since they responed to the survey.

#2a) x <- sum(na.omit(news\(fb_share[news\)pro ==‘Trump’])) y <- sum(na.omit(news\(fb_share[news\)pro ==‘Clinton’])) #2b) cat(x, ‘pro-Trump articles were shared on Facebook, and’, y, ‘pro-Clinton articles were shared, in this dataset.’) #There are more pro Trump articles than pro Clinton articles shared in facebook

#3 articles_total <- news\(buzzfeed + news\)snopes + news$politifact

buzzfeed_total <- sum(news\(buzzfeed == 1) snopes_total <- sum(news\)snopes == 1) politifact_total <- sum(news$politifact == 1)

buzzfeed_exclusive <- sum(news\(buzzfeed == 1 & articles_total == 1) snopes_exclusive <- sum(news\)snopes == 1 & articles_total == 1) politifact_exclusive <- sum(news$politifact == 1 & articles_total == 1)

buzzfeed_per <- round(100 * buzzfeed_exclusive/buzzfeed_total) snopes_per <- round(100 * snopes_exclusive/snopes_total) politifact_per <- round(100 * politifact_exclusive/politifact_total)

cat(‘Highest share of exclusive articles is snopes with’,snopes_per ,“%”)

#4 avg_time <- round(mean(na.omit(survey$MediaMinutesPerDay)))

news_sometimes <- survey$MediaMinutesPerDay > 0

social_media_per <- (100 * survey\(SocialMediaMinutesPerDay[news_sometimes]/survey\)MediaMinutesPerDay[news_sometimes])

avg_social_media_per <- round(mean(social_media_per))

cat(‘On average respondents spent’, avg_time, ‘minutes consuming election news,’,avg_social_media_per,‘percent of the time on social media, and the vast majority of respondents time was spent on social media.’)

#Social media as a source is relatively important only being beat out by Cable TV and Website

Including Plots

#5

setwd("~/Desktop/Econ 124/Data")
survey <- read.csv('survey.csv')

media_counts <- table(survey$MostImportantSource)
media_counts <- media_counts/15
media_counts <- sort(media_counts)

barplot(media_counts, las = 2, main = "Most Important source of news for respondents", ylab = "Number of Respondents")