Introducción

A continuación presentremos un listado de las estadísticas descriptivas básicas para el análisis de datos y posteriormente veremos como realizar los cálculos con los códigos en R:

Estadísticas de Tendencia Central

  • Promedio
  • Mediana
  • Moda
#Generamos 100 datos aleatorios
x <- rnorm(100,5,2)
#Visualizamos los datos
print(x)
##   [1] 3.3953049 4.9311568 5.8131038 3.9730524 1.3395759 5.0961561 2.1368305
##   [8] 8.4260346 5.5540323 4.8188548 5.9218509 7.4064252 3.8855587 6.0092466
##  [15] 7.3252038 6.5010069 6.4007763 2.9712167 5.2891235 5.0693464 1.9223859
##  [22] 4.5547375 2.6220577 1.3016141 4.7778652 0.7143055 4.3604025 5.4256681
##  [29] 5.8428515 6.5764803 3.0130273 0.5353360 5.1002867 5.4236464 8.9709729
##  [36] 4.3678488 1.5827808 1.1921300 9.8687481 1.6018734 5.1432785 6.8574151
##  [43] 2.4738545 6.7239856 4.1464411 7.1065176 7.6861651 3.6335536 4.9306049
##  [50] 3.1259082 6.0462720 3.6827195 6.1779080 5.9046498 4.8862887 4.8667844
##  [57] 6.9784232 6.2482103 5.4758424 9.7565482 6.1448775 4.9879733 7.0933677
##  [64] 3.2642889 2.0013622 7.3477660 6.0775990 4.1345067 5.3825838 0.2233282
##  [71] 4.6011122 3.8048620 3.4886812 5.8232102 8.5100991 7.8101362 3.6725165
##  [78] 3.1564508 4.1296090 6.7711109 4.7224903 3.5955213 4.4660947 6.5127090
##  [85] 5.2194789 4.4918323 6.5012707 3.3089665 4.7003831 7.9344484 6.0312740
##  [92] 3.9440818 6.4699005 2.7671052 0.8582597 4.5032439 7.1944026 3.3247749
##  [99] 4.2112628 2.9393632
#Calculamos la media
mean(x)
## [1] 4.859926

Gráficos en R

A continuación mostraremos un ejemplo de como generar un histograma

hist(x, col="green")

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:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

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