- On your blog, write 2–3 paragraphs addressing:
- Key patterns you observe (e.g., which candidate shows the largest discrepancies).
- Impact of using made‑up data—what limitations does this introduce?
- How you might collect or validate real poll data in a true analysis.
Looking at the data, Donald shows very high numbers in both polls, but CBS rates him even higher than ABC, resulting in one of the largest positive differences. On the other hand, Ted has a strong ABC showing (51%) but weaker support in CBS (43%), producing a negative gap. Smaller candidates like Carly and Jeb also show discrepancies, but because their overall numbers are low, the differences are less impactful. The new column Diff makes these gaps clearer at a glance. Since this dataset is fictional, the results can only highlight how differences between polls might appear rather than reflect reality. Made-up numbers ignore real-world factors such as sample size, methodology, or timing of the poll, which can drastically affect results. Using synthetic data is useful for practicing R coding and statistical workflows but cannot inform actual political analysis.
R Studio Code:
> # Define vectors
> Name <- c("Jeb", "Donald", "Ted", "Marco", "Carly", "Hillary", "Bernie")
> ABC_poll <- c(4, 62, 51, 21, 2, 14, 15)
> CBS_poll <- c(12, 75, 43, 19, 1, 21, 19)
>
> # Combine into a data frame
> df_polls <- data.frame(Name, ABC_poll, CBS_poll)
>
> # Inspect structure and first rows
> str(df_polls)
'data.frame': 7 obs. of 3 variables:
$ Name : chr "Jeb" "Donald" "Ted" "Marco" ...
$ ABC_poll: num 4 62 51 21 2 14 15
$ CBS_poll: num 12 75 43 19 1 21 19
> head(df_polls)
Name ABC_poll CBS_poll
1 Jeb 4 12
2 Donald 62 75
3 Ted 51 43
4 Marco 21 19
5 Carly 2 1
6 Hillary 14 21
>
> # Summary statistics
> mean(df_polls$ABC_poll)
[1] 24.14286
> median(df_polls$CBS_poll)
[1] 19
> range(df_polls[, c("ABC_poll", "CBS_poll")])
[1] 1 75
>
> # Add a new column for differences
> df_polls$Diff <- df_polls$CBS_poll - df_polls$ABC_poll
>
> # Quick plot
> barplot(df_polls$Diff, names.arg = df_polls$Name,
+ col = "steelblue", main = "Difference: CBS - ABC Polls",
+ ylab = "Difference in Poll %")
ggplot2 graphic:
|
Comments
Post a Comment