Ejemplo 2

require(ggplot2)
## Loading required package: ggplot2
require(plotly)
## Loading required package: plotly
## Warning: package 'plotly' was built under R version 3.6.2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
load("~/Desktop/casos_ins.RData")


##Series de Tiempo (tendencia...)
class(casos_ins$fecha_de_notificaci_n)
## [1] "character"
casos_ins$fecha_not=as.Date(casos_ins$fecha_de_notificaci_n)
casos_ins$fis=as.Date(casos_ins$fis)

p6=ggplot(casos_ins,aes(x=fis))+geom_bar()+theme_bw()
p6
## Warning: Removed 87 rows containing non-finite values (stat_count).

p7=ggplot(casos_ins,aes(x=estado))+geom_bar()+theme_bw()
p7

class(casos_ins$fis)
## [1] "Date"
tabla1=table(casos_ins$fis)
tabla1=data.frame(tabla1)
names(tabla1)=c("Fecha_Sintomas","Casos")
tabla1
##     Fecha_Sintomas Casos
## 1       2020-03-02     1
## 2       2020-03-05     1
## 3       2020-03-07     1
## 4       2020-03-09     4
## 5       2020-03-10     4
## 6       2020-03-11     2
## 7       2020-03-12     9
## 8       2020-03-13     6
## 9       2020-03-14    10
## 10      2020-03-15    16
## 11      2020-03-16    16
## 12      2020-03-17    14
## 13      2020-03-18    19
## 14      2020-03-19    20
## 15      2020-03-20    35
## 16      2020-03-21    19
## 17      2020-03-22    14
## 18      2020-03-23    26
## 19      2020-03-24    25
## 20      2020-03-25    27
## 21      2020-03-26    22
## 22      2020-03-27    16
## 23      2020-03-28    19
## 24      2020-03-29    10
## 25      2020-03-30    23
## 26      2020-03-31    16
## 27      2020-04-01    23
## 28      2020-04-02    20
## 29      2020-04-03    17
## 30      2020-04-04    14
## 31      2020-04-05    18
## 32      2020-04-06    20
## 33      2020-04-07    17
## 34      2020-04-08    14
## 35      2020-04-09    27
## 36      2020-04-10    12
## 37      2020-04-11    17
## 38      2020-04-12    18
## 39      2020-04-13    34
## 40      2020-04-14    22
## 41      2020-04-15    27
## 42      2020-04-16    11
## 43      2020-04-17    14
## 44      2020-04-18    28
## 45      2020-04-19    23
## 46      2020-04-20    43
## 47      2020-04-21    25
## 48      2020-04-22    32
## 49      2020-04-23    23
## 50      2020-04-24    27
## 51      2020-04-25    26
## 52      2020-04-26    33
## 53      2020-04-27    33
## 54      2020-04-28    33
## 55      2020-04-29    28
## 56      2020-04-30    31
## 57      2020-05-01    69
## 58      2020-05-02    52
## 59      2020-05-03    36
## 60      2020-05-04    57
## 61      2020-05-05    54
## 62      2020-05-06    49
## 63      2020-05-07    54
## 64      2020-05-08    65
## 65      2020-05-09    86
## 66      2020-05-10    80
## 67      2020-05-11    68
## 68      2020-05-12    71
## 69      2020-05-13    94
## 70      2020-05-14    94
## 71      2020-05-15    96
## 72      2020-05-16    86
## 73      2020-05-17    70
## 74      2020-05-18   122
## 75      2020-05-19    92
## 76      2020-05-20   132
## 77      2020-05-21    91
## 78      2020-05-22   103
## 79      2020-05-23    98
## 80      2020-05-24    73
## 81      2020-05-25   107
## 82      2020-05-26   106
## 83      2020-05-27   109
## 84      2020-05-28   138
## 85      2020-05-29   118
## 86      2020-05-30   122
## 87      2020-05-31    99
## 88      2020-06-01   247
## 89      2020-06-02   131
## 90      2020-06-03   132
## 91      2020-06-04   111
## 92      2020-06-05   243
## 93      2020-06-06   173
## 94      2020-06-07   129
## 95      2020-06-08   218
## 96      2020-06-09   201
## 97      2020-06-10   221
## 98      2020-06-11   234
## 99      2020-06-12   203
## 100     2020-06-13   162
## 101     2020-06-14   150
## 102     2020-06-15   191
## 103     2020-06-16   233
## 104     2020-06-17   221
## 105     2020-06-18   207
## 106     2020-06-19   245
## 107     2020-06-20   268
## 108     2020-06-21   215
## 109     2020-06-22   349
## 110     2020-06-23   346
## 111     2020-06-24   316
## 112     2020-06-25   421
## 113     2020-06-26   419
## 114     2020-06-27   371
## 115     2020-06-28   371
## 116     2020-06-29   418
## 117     2020-06-30   481
## 118     2020-07-01   590
## 119     2020-07-02   498
## 120     2020-07-03   465
## 121     2020-07-04   439
## 122     2020-07-05   437
## 123     2020-07-06   662
## 124     2020-07-07   550
## 125     2020-07-08   494
## 126     2020-07-09   567
## 127     2020-07-10   639
## 128     2020-07-11   517
## 129     2020-07-12   487
## 130     2020-07-13   619
## 131     2020-07-14   656
## 132     2020-07-15   567
## 133     2020-07-16   578
## 134     2020-07-17   567
## 135     2020-07-18   518
## 136     2020-07-19   432
## 137     2020-07-20   555
## 138     2020-07-21   577
## 139     2020-07-22   454
## 140     2020-07-23   487
## 141     2020-07-24   524
## 142     2020-07-25   539
## 143     2020-07-26   423
## 144     2020-07-27   739
## 145     2020-07-28   486
## 146     2020-07-29   560
## 147     2020-07-30   466
## 148     2020-07-31   497
## 149     2020-08-01   684
## 150     2020-08-02   535
## 151     2020-08-03   522
## 152     2020-08-04   590
## 153     2020-08-05   438
## 154     2020-08-06   446
## 155     2020-08-07   391
## 156     2020-08-08   389
## 157     2020-08-09   430
## 158     2020-08-10   467
## 159     2020-08-11   361
## 160     2020-08-12   407
## 161     2020-08-13   341
## 162     2020-08-14   304
## 163     2020-08-15   266
## 164     2020-08-16   215
## 165     2020-08-17   239
## 166     2020-08-18   277
## 167     2020-08-19   247
## 168     2020-08-20   238
## 169     2020-08-21   176
## 170     2020-08-22   141
## 171     2020-08-23    92
## 172     2020-08-24   117
## 173     2020-08-25    85
## 174     2020-08-26    51
## 175     2020-08-27    24
## 176     2020-08-28     2
## 177     2020-08-29     1
tabla1$Fecha_Sintomas=as.Date(tabla1$Fecha_Sintomas)

p8=ggplot(tabla1,aes(x=Fecha_Sintomas,y=Casos))+geom_point()+theme_bw()
p8+geom_smooth(method = "lm")
## `geom_smooth()` using formula 'y ~ x'

p8+geom_smooth(method = "glm")
## `geom_smooth()` using formula 'y ~ x'

p8+geom_smooth(method = "loess")
## `geom_smooth()` using formula 'y ~ x'

p8+geom_smooth(method = "gam")
## `geom_smooth()` using formula 'y ~ s(x, bs = "cs")'