datos=c(6,3,7,4,5,3)
A=matrix(data=datos,nrow=3,ncol=2,byrow=FALSE)
print(A*3)
## [,1] [,2]
## [1,] 18 12
## [2,] 9 15
## [3,] 21 9
matA<-matrix(data=c("a","b","c","d","e","f"),nrow=3,ncol=2,byrow=TRUE)
rownames(matA)<-c("Fila1","Fila2","Fila3")
colnames(matA)<-c("Col1","Col2")
print(matA)
## Col1 Col2
## Fila1 "a" "b"
## Fila2 "c" "d"
## Fila3 "e" "f"
class(matA)
## [1] "matrix" "array"
print(is.matrix(matA))
## [1] TRUE
Fórmulas estadísticas
x<-c(4,2,7,8,4,6,5,8,3)
media<-mean(x)
desvSTD<-sd(x)
varianza<-var(x)
print(media)
## [1] 5.222222
print(desvSTD)
## [1] 2.166667
print(varianza)
## [1] 4.694444
x<-c(0,1,2,3,4,5)
y<-c(2.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
## 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(0.35238,0.93771,col="blue")
