datos=c(6,4,5,3,8,0)
A=matrix(data=datos,nrow=3,ncol=2,byrow = FALSE)
print(A*3)
## [,1] [,2]
## [1,] 18 9
## [2,] 12 24
## [3,] 15 0
matA=matrix(data = c("a", "b", "c", "d", "e", "f"), nrow = 3, ncol = 2, byrow=FALSE)
rownames(matA)=c("fila1","fila2","fila3")
colnames(matA)=c("col1","col2")
print(matA)
## col1 col2
## fila1 "a" "d"
## fila2 "b" "e"
## fila3 "c" "f"
class(matA)
## [1] "matrix" "array"
print(is.matrix(matA))
## [1] TRUE
Fórmulas estadísticas
x=c(2,3,5,6,1,0,5,3,4)
media=mean(x)
desvSTD=sd(x)
varianza=var(x)
print(media)
## [1] 3.222222
print(desvSTD)
## [1] 1.986063
print(varianza)
## [1] 3.944444
x=c(0,1,2,3,4,5)
y=c(0.5,1.4,1.98,3.1,3.8,5.4)
formula1=formula(y~x)
modelo=lm(formula1)
summary(modelo)
##
## Call:
## lm(formula = formula1)
##
## Residuals:
## 1 2 3 4 5 6
## 0.14762 0.10990 -0.24781 -0.06552 -0.30324 0.35905
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.35238 0.20485 1.72 0.160511
## x 0.93771 0.06766 13.86 0.000157 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.283 on 4 degrees of freedom
## Multiple R-squared: 0.9796, Adjusted R-squared: 0.9745
## F-statistic: 192.1 on 1 and 4 DF, p-value: 0.0001571
plot(x,y)
abline(0.35238,0.93771,col="purple")
