UNIVERSIDAD CENTRAL DEL ECUADOR

FACULTAD DE CIENCIAS ECONÓMICAS

INGENIERIA EN ESTADÍSTICA

GRUPO 2

APLICANDO LOS CONOCIMIENTOS DE RSTUDIO

En este documento se presentan los ejercicios resueltos del taller #6 haciendo uso de RMarkdown

AUTORES

COLABORACIÓN

EJERCICIOS 1

- EJERCICIO

\[ A= \begin{pmatrix} 1&2&3\\ 2&4&6\\ 3&6&9\\ 4&8&12\\ \end{pmatrix} \]

A <- matrix(c(1,2,3,2,4,6,3,6,9,4,8,12),ncol = 3, byrow = T)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    2    4    6
## [3,]    3    6    9
## [4,]    4    8   12

- EJERCICIO 2

\[ I= \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\\ \end{pmatrix} \]

I<-diag(c(1,1,1,1))
I
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    0    1    0    0
## [3,]    0    0    1    0
## [4,]    0    0    0    1

- EJERCICIO 3

\[ L= \begin{pmatrix} 1&2&-4\\ -1&-1&5\\ 2&7&-3\\ \end{pmatrix} \]

L <- matrix(c(1,2,-4,-1,-1,5,2,7,-3), ncol=3, byrow = T)
L
##      [,1] [,2] [,3]
## [1,]    1    2   -4
## [2,]   -1   -1    5
## [3,]    2    7   -3
# Instalación del paquete "matlib"

# install.packages("matlib")
library(matlib)
## Warning: package 'matlib' was built under R version 4.2.2
# Matriz inversa de L

L2<-Inverse(L)
L2
##       [,1]  [,2] [,3]
## [1,] -16.0 -11.0  3.0
## [2,]   3.5   2.5 -0.5
## [3,]  -2.5  -1.5  0.5

- EJERCICIO 4 -Suponga que se quiere ingresar una matriz con muchas entradas como la matriz P que se presenta a continuación. hacerlo pero desde un archivo en excel (investigar como hacerlo)

\[ P= \begin{pmatrix} 1&2&3&0&2\\ 2&4&6&0&3\\ 3&6&9&0&5\\ 4&8&12&0&7\\ 5&10&15&5&11\\ 6&12&18&5&13\\ 7&14&21&5&17\\ 8&16&24&5&19\\ 9&18&27&5&23\\ \end{pmatrix} \]

#PASO 1: Se instala el paquete readxl, conjuntamente con su libreria para #importar 
#datos de excel
#install.packages("readxl")
#library(readxl)
#PASO 2: Se usa el comando file.choose(), una ventana se desplegará en la pantalla y 
#seleccionamos nuestro archivo excel
file.choose()
## [1] "C:\\Users\\PC\\Downloads\\Matriz.xlsx"
#PASO 3: Se guarda la matriz en una nueva variable.
#datosmatriz<-read_excel("C:\\Users\\PC\\Downloads\\Matriz.xlsx")
#PASO 4: Se transforma el dataframe a una matriz.
#n<-data.matrix(datosmatriz)
#n
#PASO 5: Se verifica si n es una matriz con: is.matrix()
#is.matrix(n)

- EJERCICIO 5

$$

{ \[\begin{array}{ll} x +5y =7\\ -2x-7y=-5 \end{array}\]

. $$

a <- rbind(c(1, 5),c(-2, -7))
a
##      [,1] [,2]
## [1,]    1    5
## [2,]   -2   -7
b <- c(7, -5)
b
## [1]  7 -5
solve(a, b)
## [1] -8  3

- EJERCICIO 6

-Realice el determinate de la siguiente matriz, la solución manual se adjunta, usted debe realizarlo por R, puede usar la funcion det y comprobar los resultados.

\[ A= \begin{pmatrix} 1&4&9\\ 7&2&5\\ 6&8&3\\ \end{pmatrix} \] \[ \begin{array}{ll} |A| = (1*2*3)\\ \ \ \ \ \ +(4*5*6)\\ \ \ \ \ \ +(7*8*9)\\ \ \ \ \ \ -(9*2*6)\\ \ \ \ \ \ -(4*7*3)\\ \ \ \ \ \ -(5*8*1)\\ \ \ \ \ \ =6+120+504-108-84-40\\ \ \ \ \ \ =398 \end{array} \]

c <- matrix(c(1,4,9,7,2,5,6,8,3), nrow =  3, byrow =  T)
c
##      [,1] [,2] [,3]
## [1,]    1    4    9
## [2,]    7    2    5
## [3,]    6    8    3
det(c)
## [1] 398

- EJERCICIO 7

\[ A= \begin{pmatrix} 1&2&3\\ 4&5&6\\ 7&8&9\\ \end{pmatrix} \] \[ A^T= \begin{pmatrix} 1&4&7\\ 2&5&8\\ 3&6&9\\ \end{pmatrix} \]

B <- matrix(1:9, nrow = 3, byrow = T)
B
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    4    5    6
## [3,]    7    8    9
t(B)
##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    2    5    8
## [3,]    3    6    9