library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.0.1 ✓ dplyr 1.0.0
## ✓ tidyr 1.1.0 ✓ stringr 1.4.0
## ✓ readr 2.1.1 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
cels<- read_csv(url("https://d3c33hcgiwev3.cloudfront.net/gNPzTMk-SeGT80zJPknhBg_2261b39121e04293b7f043b946874e7c_cces_sample_coursera.csv?Expires=1767457606&Signature=JUYqEHP47mAhI~FgUhf~ErHHz1VUO9r3mHfHIxQrp8KSb-dSWpdgWray5953yBZJj~8nhytkPcKsRO9D3~wpA4HJpkDzk4HcfZ2LhImoPke0nzYcVM8Puk76ZDqq9ThKd2sgRrRLvoT1lBi~f5csJYjG6JpskE7KP~ymrbg23S0_&Key-Pair-Id=APKAJLTNE6QMUY6HBC5A"))
## Rows: 1000 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (25): caseid, region, gender, educ, edloan, race, hispanic, employ, mars...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
names(cels)
## [1] "caseid" "region" "gender" "educ" "edloan"
## [6] "race" "hispanic" "employ" "marstat" "pid7"
## [11] "ideo5" "pew_religimp" "newsint" "faminc_new" "union"
## [16] "investor" "CC18_308a" "CC18_310a" "CC18_310b" "CC18_310c"
## [21] "CC18_310d" "CC18_325a" "CC18_325b" "CC18_325c" "CC18_325d"
cels <- cels %>%
mutate(
Ideology = case_when(
ideo5 == 1 ~ "Very Liberal",
ideo5 == 2 ~ "Liberal",
ideo5 == 3 ~ "Moderate",
ideo5 == 4 ~ "Conservative",
ideo5 == 5 ~ "Very Conservative",
TRUE ~ NA_character_
),
Religion_Imp = case_when(
pew_religimp == 1 ~ "Very imp.",
pew_religimp == 2 ~ "Somewhat imp.",
pew_religimp == 3 ~ "Not too imp.",
pew_religimp == 4 ~ "Not imp.",
TRUE ~ NA_character_
)
)
ggplot(cels,
aes(x = Religion_Imp, fill = Ideology)) +
geom_bar() +
labs(
title = "Importance of Religion by Ideology",
x = "Importance of Religion",
y = "Count",
fill = "Ideology"
) +
theme_minimal()

set.seed(123)
grades <- tibble(
Semester = rep(1:6,times = 3),
Student= rep(c("Amansa","Betty","Carol"),each = 6),
Grade = runif(18,min=80,max=100)
)
ggplot(grades,
aes(x= Semester, y= Grade, color= Student))+
geom_line() +
geom_point() +
labs(
title = "Student Grades by Semester",
x="Semester",
y="Grade"
) +
theme_minimal()
