library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(lubridate)
## 
## Attaching package: 'lubridate'
## 
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(readxl)
basefechas <- read_excel("C:/Users/fidel/OneDrive - CINVESTAV/PROYECTO MDatos/TRABAJOS/Dr. Lauro Varela NUEVO PROYECTO/basefechas.xlsx", 
    col_types = c("text", "date", "numeric", 
        "text"))

#Gráfico

library(ggplot2)
# Line plot with multiple groups
ggplot(data=basefechas, aes(x=fecha, y=Valor, group=IB)) +
  geom_line(aes(linetype=IB, color=IB))+
  geom_point(aes(color=IB), xlim=10)
## Warning: Ignoring unknown parameters: xlim
## Warning: Removed 71 row(s) containing missing values (geom_path).
## Warning: Removed 71 rows containing missing values (geom_point).

# Multiple line plot
p<-ggplot(basefechas, aes(x = fecha, y = Valor)) + 
  geom_line(aes(color = IB), size = 1) +
  theme_minimal()
p
## Warning: Removed 71 row(s) containing missing values (geom_path).

#IBNI

IBNI <- basefechas %>% filter(IB == "IBNI")

ggplot(IBNI, aes(x = fecha, y = Valor)) + 
  geom_line(aes(color = IB), size = 1) +
  theme_minimal()
## Warning: Removed 10 row(s) containing missing values (geom_path).

IB2 <- basefechas %>% filter(IB == "IB2")

ggplot(IB2, aes(x = fecha, y = Valor)) + 
  geom_line(aes(color = IB), size = 1,color = "Blue")+
  theme_minimal()
## Warning: Removed 14 row(s) containing missing values (geom_path).

IB3 <- basefechas %>% filter(IB == "IB3")

ggplot(IB3, aes(x = fecha, y = Valor)) + 
  geom_line(aes(color = IB), size = 1,color = "Green")+
  theme_minimal()
## Warning: Removed 13 row(s) containing missing values (geom_path).

IB4 <- basefechas %>% filter(IB == "IB4")

ggplot(IB4, aes(x = fecha, y = Valor)) + 
  geom_line(aes(color = IB), size = 1,color = "Purple")+
  theme_minimal()
## Warning: Removed 15 row(s) containing missing values (geom_path).

IB4 <- basefechas %>% filter(IB == "IB4")

ggplot(IB2, aes(x = fecha, y = Valor)) + 
  geom_line(aes(color = IB), size = 1,color = "skyblue")+
  theme_minimal()
## Warning: Removed 14 row(s) containing missing values (geom_path).

library(gtsummary)
basefechas %>% select(fecha, IB) %>%  tbl_summary(by=IB) 
## Warning: The `fmt_missing()` function is deprecated and will soon be removed
## * Use the `sub_missing()` function instead
Characteristic IB2, N = 421 IB3, N = 411 IB4, N = 421 IB5, N = 421 IBNI, N = 421
fecha 2005-09-13 to 2019-02-27 2005-10-31 to 2019-02-15 2007-05-22 to 2019-05-20 2008-07-14 to 2021-07-09 2004-05-28 to 2018-05-08
Unknown 14 13 15 19 10
1 Range