install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
install.packages("ggthemes")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(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.5.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── 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(ggthemes)
# ساخت دیتافریم درباره نرخ سواد و ورزش زنان ایران
iran_data <- data.frame(
Year = c(1355, 1365, 1375, 1385, 1390),
Literacy_Rate_Women = c(35.5, 52.1, 74.2, 80.3, 81.1),
Sports_Participation_Rate = c(10, 15, 22, 30, 36),
Inactive_Women_Sports = c(90, 85, 78, 70, 64)
)
ggplot(iran_data, aes(x = Year, y = Literacy_Rate_Women)) +
geom_line(color = "darkblue", size = 1.5) +
geom_point(size = 3, color = "blue") +
labs(title = "روند افزایش نرخ سواد زنان در ایران",
x = "سال", y = "درصد سواد") +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

ggplot(iran_data, aes(x = Year, y = Sports_Participation_Rate)) +
geom_line(color = "darkgreen", size = 1.5) +
geom_point(size = 3, color = "green") +
labs(title = "افزایش مشارکت ورزشی زنان در ایران",
x = "سال", y = "درصد مشارکت") +
theme_minimal()

# تبدیل دیتا به فرمت بلند
iran_long <- pivot_longer(iran_data,
cols = c(Literacy_Rate_Women, Sports_Participation_Rate),
names_to = "شاخص",
values_to = "درصد")
# رسم نمودار ترکیبی
ggplot(iran_long, aes(x = Year, y = درصد, color = شاخص)) +
geom_line(size = 1.5) +
geom_point(size = 3) +
labs(title = "مقایسه نرخ سواد و مشارکت ورزشی زنان در ایران",
x = "سال", y = "درصد") +
theme_minimal() +
scale_color_manual(values = c("Literacy_Rate_Women" = "blue",
"Sports_Participation_Rate" = "green"))
