R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

rmarkdown::render(“C5T2_Documento_v_4.Rmd”)

rm(list=ls())
library(dplyr)
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(readr)

data <-  read.csv("C://R//WHO-COVID-19-global-daily-data_v2.csv",header=TRUE, sep=",")

summary(data)
##  Date_reported      Country_code         Country           WHO_region       
##  Length:437280      Length:437280      Length:437280      Length:437280     
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##    New_cases       Cumulative_cases      New_deaths       Cumulative_deaths
##  Min.   : -65079   Min.   :        0   Min.   :-3520.00   Min.   :      0  
##  1st Qu.:      3   1st Qu.:     5393   1st Qu.:    0.00   1st Qu.:     34  
##  Median :     62   Median :    50933   Median :    0.00   Median :    649  
##  Mean   :   3740   Mean   :  1902056   Mean   :   33.92   Mean   :  20737  
##  3rd Qu.:    690   3rd Qu.:   596822   3rd Qu.:    7.00   3rd Qu.:   7475  
##  Max.   :6966046   Max.   :103436829   Max.   :44047.00   Max.   :1210707  
##  NA's   :229503                        NA's   :228566
# Formato de valores en miles
data$New_cases <- data$New_cases / 1000
data$New_deaths <- data$New_deaths / 1000
data$Cumulative_deaths <- data$Cumulative_deaths / 1000
# Formato de fechas por mes y año
data$Date_reported <- as.Date(data$Date_reported)
data$YearMonth <- format(data$Date_reported, "%Y-%m")




# Agrupaciones
library(dplyr)

# 1. Agrupar por WHO_region y New_cases
grouped_cases <- data %>%
  group_by(WHO_region) %>%
  summarise(Total_New_Cases = sum(New_cases, na.rm = TRUE))

# 2. Agrupo por WHO_region y New_deaths
grouped_deaths <- data %>%
  group_by(WHO_region) %>%
  summarise(Total_New_Deaths = sum(New_deaths, na.rm = TRUE))

# 3. Agrupo por WHO_region y Cumulative_deaths
grouped_cum_deaths <- data %>%
  group_by(WHO_region) %>%
  summarise(Total_Cumulative_Deaths = sum(Cumulative_deaths, na.rm = TRUE))

# 4. Agrupo por Country_Code y Cumulative_deaths
grouped_country_cum_deaths <- data %>%
  group_by(Country_code) %>%
  summarise(Total_Cumulative_Deaths = sum(Cumulative_deaths, na.rm = TRUE))


library(ggplot2)

Including Plots

You can also embed plots, for example:

## Warning: Removed 229504 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 229504 rows containing missing values or values outside the scale range
## (`geom_point()`).

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.