trabajar con el conjunto de datos women
determinar
media, mediana,moda, frecuencia, desv std, varianza, cuartiles, percentiles
cargar una variable en w<- women
w <- women
# cuantas variables
#cuantas observaciones
#que tipos de datos tiene
str(w)
## 'data.frame': 15 obs. of 2 variables:
## $ height: num 58 59 60 61 62 63 64 65 66 67 ...
## $ weight: num 115 117 120 123 126 129 132 135 139 142 ...
class(w)
## [1] "data.frame"
sacar el min y el maximo de la altura de las personas
max(w$height)
## [1] 72
min(w$height)
## [1] 58
generar nuemroa aleatorios entre 79 y 100 con semilla
set.seed(10)
numeros<- sample (70:100,size =100,replace = TRUE)
numeros
## [1] 85 79 83 91 72 76 78 78 89 83 90 87 73 88 81 83 71 78 82 95 96 89 94
## [24] 81 82 91 95 77 93 81 86 72 75 97 83 93 95 99 91 85 78 77 70 92 77 74
## [47] 70 85 73 94 80 99 77 84 75 88 84 84 82 85 70 73 84 82 95 93 87 83 72
## [70] 76 72 86 89 86 71 86 81 99 77 76 96 84 76 89 76 70 94 78 75 75 85 92
## [93] 88 86 81 95 77 86 93 70
#sacamos la moda de los numeros
table(numeros)
## numeros
## 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
## 5 2 4 3 1 4 5 6 5 1 1 5 4 5 5 5 6 2 3 4 1 3 2 4 3
## 95 96 97 99
## 5 2 1 3
visualizar datos
plot(numeros)

plot(x=1:100 ,y=numeros,type="l") # type puede ser p, l, b

generando un histograma
hist(x=numeros,breaks=30, col="pink")

hist(x=numeros,breaks=70, col="pink")

generando un histograma con muchos datos
w <- women
barplot (w$height, col="blue",xlab = "Personas", ylab =" Alturas", names.arg = 1:length (w$height), main = "Height de W")

grafica de tallo y hoja
numeros
## [1] 85 79 83 91 72 76 78 78 89 83 90 87 73 88 81 83 71 78 82 95 96 89 94
## [24] 81 82 91 95 77 93 81 86 72 75 97 83 93 95 99 91 85 78 77 70 92 77 74
## [47] 70 85 73 94 80 99 77 84 75 88 84 84 82 85 70 73 84 82 95 93 87 83 72
## [70] 76 72 86 89 86 71 86 81 99 77 76 96 84 76 89 76 70 94 78 75 75 85 92
## [93] 88 86 81 95 77 86 93 70
stem(numeros)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 7 | 000001122223334
## 7 | 555566666777777888889
## 8 | 01111122223333344444
## 8 | 55555666666778889999
## 9 | 0111223333444
## 9 | 55555667999
median (numeros)
## [1] 83
grafica de cajas
boxplot(numeros)

#barplot(median)
cuartiles de distribucion
quantile(numeros)
## 0% 25% 50% 75% 100%
## 70 77 83 89 99
summary de los datos
summary(numeros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 70.00 77.00 83.00 83.29 89.00 99.00
haciendo un pastel con otro distribucion de datos con variables categoricas
datos <-data.frame(nombre= c("Hugo", "Paco", "Luis","Paty","Robert", "Mary"), genero= c('M','M', 'M','F', 'M', 'F'))
datos
## nombre genero
## 1 Hugo M
## 2 Paco M
## 3 Luis M
## 4 Paty F
## 5 Robert M
## 6 Mary F
table(datos)
## genero
## nombre F M
## Hugo 0 1
## Luis 0 1
## Mary 1 0
## Paco 0 1
## Paty 1 0
## Robert 0 1
table(datos$genero)
##
## F M
## 2 4