#PUNTO 1
x = c(1, 3, 5, 7, 9)
y = c(2, 4, 6, 7, 11, 12)
c = x+1
d = y*2
e = length(x);length(y)
## [1] 6
f = (x+y)
## Warning in x + y: longitud de objeto mayor no es múltiplo de la longitud de uno
## menor
g = sum(x>5)
G = sum(x[x>5])
h = sum(x>5 | x<3)
i = y[2]
j = y[-2]
k = y[x]
## se usa NA para representar datos perdidos
m = y[y>=8]
#PUNTO 2
#a
millas = c(65241, 65665, 65998, 66014, 66547, 66857, 67025, 67447, 66958, 67002)
#b
kms = 1.60934*millas
#C
diferencia = diff(kms)
#d
resumen = summary(diferencia)
#PUNTO 3
pago = c(47,32,40,36,49,31,49,30,49,35,48,32)
costo = sum(pago)
promedio = mean(pago)
maximo = max(pago)
minimo = min(pago)
mes = c("enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre")
mes_pago = mes[pago > 40]
mes_40 = pago[pago > 40]
porcentaje = (sum(mes_40)*100)/sum(pago)
#PUNTO 4
datos = c(61, 88, 73, 49, 41, 72, 99, 07, 12, 13, 87, 91, 05, 17, 97)
etiquetas <- paste0(round(100 * datos/sum(datos), 2), "%")
pie(datos, labels = etiquetas)

pie(datos, labels = etiquetas, main="Diagrama de tarta")

dev.off()
## null device
## 1
summary(datos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.00 15.00 61.00 54.13 87.50 99.00
fivenum(datos)
## [1] 5.0 15.0 61.0 87.5 99.0
#PUNTO 5
valor_normal = rnorm(100)
histograma = hist(valor_normal)

resumen = summary(valor_normal)
#PUNTO6
valores_bi = rbinom(30,5,0.9)
barplot(rbinom(30,5,0.9))

resumen_bi = summary(valores_bi)
#PUNTO 7
datos_satelite = c(0, 1, 0, NA, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 3, 0, 0, 0, 0, 0, 2, 0, 1)
boxplot(datos_satelite)

barplot(datos_satelite)

datos_satelite = datos_satelite[!is.na(datos_satelite)]
mean(datos_satelite)
## [1] 0.4545455
#PUNTO 8
Estudiante = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
P1 = c(3, 3, 3, 4, 3, 4, 3, 4, 4, 3)
P2 = c (5, 5, 2, 2, 5, 2, 2, 5, 5, 2)
P3 = c(1, 3, 1, 3, 3, 3, 1, 3, 1, 1)
tabla=c(P1,P2,P3)
matriz= matrix(tabla,3,10,byrow=TRUE)
rownames(matriz)=c("p1","p2","p3")
colnames(matriz)=paste("est",1:10)
matriz
## est 1 est 2 est 3 est 4 est 5 est 6 est 7 est 8 est 9 est 10
## p1 3 3 3 4 3 4 3 4 4 3
## p2 5 5 2 2 5 2 2 5 5 2
## p3 1 3 1 3 3 3 1 3 1 1
#c
matriz[2,]
## est 1 est 2 est 3 est 4 est 5 est 6 est 7 est 8 est 9 est 10
## 5 5 2 2 5 2 2 5 5 2
matriz[3,]
## est 1 est 2 est 3 est 4 est 5 est 6 est 7 est 8 est 9 est 10
## 1 3 1 3 3 3 1 3 1 1
#d
datos2=c(P2,P3)
datos3=matrix(datos2,2,10,byrow=TRUE);datos3
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 5 5 2 2 5 2 2 5 5 2
## [2,] 1 3 1 3 3 3 1 3 1 1
barplot(datos3,beside=F,xlab = "estudiantes")

#e
barplot(matriz,beside = T,xlab = "estudiantes")

#punto9
vector_normal <- rnorm(50)
vector_normal1 <- rnorm(50)
shapiro.test(vector_normal)
##
## Shapiro-Wilk normality test
##
## data: vector_normal
## W = 0.9718, p-value = 0.2737
shapiro.test(vector_normal1)
##
## Shapiro-Wilk normality test
##
## data: vector_normal1
## W = 0.99038, p-value = 0.9546
t.test(vector_normal, vector_normal1)
##
## Welch Two Sample t-test
##
## data: vector_normal and vector_normal1
## t = -1.4316, df = 96.312, p-value = 0.1555
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.6426843 0.1040862
## sample estimates:
## mean of x mean of y
## -0.03694554 0.23235349
#punto10
vector_normal <- rnorm(50)
vector_binomial <- rbinom(50, size = 1, prob = 0.5)
shapiro.test(vector_normal) # Prueba de normalidad para el vector_normal
##
## Shapiro-Wilk normality test
##
## data: vector_normal
## W = 0.97147, p-value = 0.2654
shapiro.test(vector_binomial) # Prueba de normalidad para el vector_binomial
##
## Shapiro-Wilk normality test
##
## data: vector_binomial
## W = 0.63157, p-value = 5.904e-10
t.test(vector_normal, vector_binomial)
##
## Welch Two Sample t-test
##
## data: vector_normal and vector_binomial
## t = -4.2175, df = 78.878, p-value = 6.537e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.8737954 -0.3134558
## sample estimates:
## mean of x mean of y
## -0.03362558 0.56000000