datos=c(5,6,7,8,9,10)
matrix(data=datos,nrow=3,ncol=2)
## [,1] [,2]
## [1,] 5 8
## [2,] 6 9
## [3,] 7 10
datos=c(5,6,7,8,9,10)
A=matrix(data=datos,nrow=3,ncol=2, byrow=TRUE)
print(A*3)
## [,1] [,2]
## [1,] 15 18
## [2,] 21 24
## [3,] 27 30
MatA<-matrix(data = c("a", "b", "c", "d", "e", "f"), nrow = 3, ncol = 2)
rownames(MatA)<-c("Fila1","Fila2","Fila3")
colnames(MatA)<-c("Col1","Col2")
print(MatA)
## Col1 Col2
## Fila1 "a" "d"
## Fila2 "b" "e"
## Fila3 "c" "f"
## [,1] [,2]
## [1,] "a" "d"
## [2,] "b" "e"
## [3,] "c" "f"
class(MatA)
## [1] "matrix" "array"
print(is.matrix(MatA))
## [1] TRUE
mat1 <- matrix(data = 1:6, nrow = 2, ncol = 3, byrow = TRUE)
rownames(mat1)
## NULL
## NULL
colnames(mat1)
## NULL
## NULL
rownames(mat1) <- c("Row 1", "Row 2")
colnames(mat1) <- c("Col 1", "Col 2", "Col 3")
mat1
## Col 1 Col 2 Col 3
## Row 1 1 2 3
## Row 2 4 5 6
## Col 1 Col 2 Col 3
## Row 1 1 2 3
## Row 2 4 5 6
##Fórmulas Estadísticas
x<-c(5,6,7,3,4,2,6,9)
media<-mean(x)
desvSTD<-sd(x)
varianza<-var(x)
print(media)
## [1] 5.25
print(desvSTD)
## [1] 2.251983
print(varianza)
## [1] 5.071429
x<-c(0,1,2,3,4,5)
y<-c(2.5,1.4,1.98,3.1,3.8,5.4)
formualal<-formula(y~x)
modelo<-lm(formualal)
summary(modelo)
##
## Call:
## lm(formula = formualal)
##
## Residuals:
## 1 2 3 4 5 6
## 1.100 -0.652 -0.724 -0.256 -0.208 0.740
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.4000 0.6072 2.306 0.0824 .
## x 0.6520 0.2006 3.251 0.0313 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.839 on 4 degrees of freedom
## Multiple R-squared: 0.7254, Adjusted R-squared: 0.6568
## F-statistic: 10.57 on 1 and 4 DF, p-value: 0.03135
plot(x,y)
abline( 1.4000 ,0.6520, col="pink")