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.8933585 6.2216754 2.4688973 5.2271069 4.5831121 3.6215591 3.5499089
##   [8] 3.5992272 4.6515837 4.0672254 8.6639561 2.5889554 6.6489972 5.1640371
##  [15] 5.4503945 1.0183169 0.9561098 6.3036929 5.1708776 2.6808954 9.1936652
##  [22] 4.5829106 2.9399476 2.1306229 5.1619084 3.1360574 4.2387127 8.5607996
##  [29] 4.3974154 6.5275125 5.2943679 7.0645032 2.9180594 4.7703949 7.5060767
##  [36] 6.7662994 4.4113400 3.3612550 4.9403435 7.8447075 3.1347476 5.7336619
##  [43] 8.2788000 5.2124070 4.6139512 3.2904034 5.3785758 4.9363276 4.0725047
##  [50] 5.1587543 5.6612876 9.8831692 5.6303639 3.3354927 6.8188457 3.5357841
##  [57] 4.2244100 9.6101756 4.9580014 3.7319052 5.5775125 7.0807597 6.3811525
##  [64] 2.2126283 2.9018647 6.1066996 4.0439894 6.9503673 5.5235647 3.8737714
##  [71] 8.6736745 8.5408244 2.7118926 6.7632797 5.4590742 3.8725487 5.3670129
##  [78] 7.1247058 4.5378179 4.7886099 3.9761491 3.0367431 0.6910553 1.2202857
##  [85] 3.7396696 4.4479821 7.6008268 6.3809917 3.4777177 4.8530993 3.9658194
##  [92] 4.3970859 7.9713575 4.9793055 2.6271603 6.2420587 6.0929464 6.1349868
##  [99] 4.6653697 5.4600316
#Calculamos la media
mean(x)
## [1] 4.999287

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.