Skip to content

wanyama

         # OSBORN WANYAMA'S R - poject PRACTICE 



library(tidyverse)
my_data <- read.csv("yearly_deaths_by_clinic.csv") %>%
  mutate(proportion_deaths = deaths / births)
my_data
ggplot(my_data, aes(x = year, y = proportion_deaths, color = clinic)) +
  geom_line() + ggtitle("YEAR VS PROPORTION DEATHS")


# Read datasets/monthly_deaths.csv into monthly
monthly <- read.csv("monthly_deaths.csv")

# Adding a new column with proportion of deaths per no. births
monthly <- monthly %>% 
  mutate(proportion_deaths = deaths / births)

# Print out the first rows in monthly
head(monthly)

ggplot(monthly, aes(date, proportion_deaths)) +
  geom_line() +
  labs(x = "Year", y = "Proportion Deaths")


# From this date handwashing was made mandatory
handwashing_start = as.Date('1847-06-01')

# Add a TRUE/FALSE to monthly called handwashing_started
monthly <- monthly %>%
  mutate(handwashing_started = date >= handwashing_start)

# Plot monthly proportion of deaths before and after handwashing
ggplot(monthly, aes(x = date, y = proportion_deaths, color = handwashing_started)) +
  geom_line()

# Calculating the mean proportion of deaths 
# before and after handwashing.

monthly_summary <- monthly %>% 
  group_by(handwashing_started) %>%
  summarise(mean_proportion_deaths = mean(proportion_deaths))

# Printing out the summary.
monthly_summary

# Calculating a 95% Confidence intrerval using t.test 
test_result <- t.test( proportion_deaths ~ handwashing_started, data = monthly)
test_result

# The data Semmelweis collected points to that:
doctors_should_wash_their_hands <- TRUE
library(readr)

# Load the dataset
data <- read_csv('yearly_deaths_by_clinic.csv')

# Perform ANOVA
anova_result <- aov(deaths ~ clinic, data = data)
summary(anova_result)
# Display the summary of the ANOVA results
summary(anova_result)