Morán-Pérez - Tarea 4 BStat - 22-02-24
Morán-Pérez - Tarea 4 BStat - 22-02-24
Ejercicio 3.3
> year <- c(1980, 1990, 1995, 1998, 1999, 2000, 2001)
> family_practice <- c(47.8, 57.6, 59.9, 64.6, 66.2, 67.5, 70.0)
> total_office_based <- c(271.3, 359.9, 427.3, 468.8, 473.2, 490.4, 514.0)
> barplot(family_practice,year, names.arg = year, xlab = "Year", ylab = "Number of
Physicians", col = "blue", main = "Increase in Family Practice Physicians (1980-2001)")
Ejercicio 3.4
> fluoride <- c(0.75, 0.86, 0.84, 0.85, 0.97, 0.94, 0.89, 0.84, 0.83, 0.89, 0.88, 0.78, 0.77, 0.76,
0.82, 0.72, 0.92, 1.05, 0.94, 0.83, 0.81, 0.85, 0.97, 0.93, 0.79)
> range_measurement <- max(fluoride) - min(fluoride)
> range_measurement
[1] 0.33
> class_interval_width <- 0.05
> lower_limit <- 0.705
> hist(fluoride, breaks = seq(lower_limit, max(fluoride) + class_interval_width, by =
class_interval_width), col = "lightblue", main = "Frequency Histogram of Fluoride Levels",
xlab = "Fluoride Levels (ppm)", ylab = "Frequency")
Ejercicio 3.7
> standard_therapy <- c(4, 15, 24, 10, 1, 27, 31, 14, 2, 16, 32, 7, 13, 36, 29, 6, 12, 18, 14, 15,
18, 6, 13, 21, 20, 8, 3, 24)
> new_therapy <- c(5, 20, 29, 15, 7, 32, 36, 17, 15, 19, 35, 10, 16, 39, 27, 14, 10, 16, 12, 13,
16, 9, 18, 33, 30, 29, 31, 27)
> num_bins <- 10
> par(mfrow = c(1, 2))
> hist(standard_therapy, breaks = num_bins, freq = FALSE, main = "Standard Therapy", xlab
= "Survival Time (months)", ylab = "Relative Frequency", col = "lightblue")
> hist(new_therapy, breaks = num_bins, freq = FALSE, main = "New Therapy", xlab =
"Survival Time (months)", ylab = "Relative Frequency", col = "lightgreen")
Ejercicio 3.39
> subsistence <- c("Shifting Cultivators", "Settled Agriculturists", "Town Dwellers")
> illiterate <- c(114, 76, 93)
> primary_schooling <- c(10, 2, 13)
> at_least_middle_school <- c(45, 53, 208)
> data <- data.frame(subsistence, illiterate, primary_schooling, at_least_middle_school)
> library(tidyr)
> data_long <- pivot_longer(data, -subsistence, names_to = "Literacy Level", values_to =
"Count"
> library(ggplot2)
> ggplot(data_long, aes(x = subsistence, y = Count, fill = `Literacy Level`)) +
geom_bar(stat="identity") + labs(title = "Literacy Level by Subsistence Group in Manipur,
India", x = "Subsistence Group", y = "Count") + theme_minimal() + scale_fill_manual(values
= c("#66c2a5", "#fc8d62", "#8da0cb"))
La mayoría de las personas analfabetas son cultivadores itinerantes, mientras que la mayoría
de la gente que terminó la secundaria habita en la ciudad.
Ejercicio 3.41
> months <- 1:20
> M2 <- c(2.25, 2.27, 2.28, 2.29, 2.31, 2.32, 2.35, 2.37, 2.40, 2.42, 2.43, 2.42, 2.44, 2.47, 2.49,
2.51, 2.53, 2.53, 2.54, 2.55)
> M3 <- c(2.81, 2.84, 2.86, 2.88, 2.90, 2.92, 2.96, 2.99, 3.02, 3.04, 3.05, 3.05, 3.08, 3.10, 3.10,
3.13, 3.17, 3.18, 3.19, 3.20)
> plot(M2, M3, main = "Scatterplot of M2 vs M3", xlab = "M2 (trillions of dollars)", ylab =
"M3 (trillions of dollars)", pch = 16, col = "blue")