Question 1

n_dims <- sample(3:9, 1)
vec <- c(1:n_dims^2)
re_vec <- sample(vec)
revec_matrix <- matrix(data=re_vec,nrow=n_dims,ncol=n_dims)
print(revec_matrix)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   12    9   10    7   14
## [2,]   16   13   19    4   21
## [3,]    2    5   20   24    3
## [4,]    1   25    8   23   17
## [5,]    6   18   22   15   11
trans_rvmx<- t(revec_matrix)
print(trans_rvmx) #changed by making rows columns and columns rows
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   12   16    2    1    6
## [2,]    9   13    5   25   18
## [3,]   10   19   20    8   22
## [4,]    7    4   24   23   15
## [5,]   14   21    3   17   11
eigen_vec <- eigen(x=trans_rvmx,symmetric=TRUE) #all of these values are doubles
typeof(eigen_vec$values) #double
## [1] "double"
typeof(eigen_vec$vectors) #double
## [1] "double"

Question 2

my_matrix <- matrix(data=runif(16),nrow=4,ncol = 4)
print(my_matrix)
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.9537999 0.63064915 0.4706896 0.9075425
## [2,] 0.7990782 0.15290807 0.6954724 0.4107923
## [3,] 0.2779337 0.06970169 0.3521289 0.1747413
## [4,] 0.8145608 0.21597537 0.4740964 0.9257668
my_logical <- c(0.5 < runif(1:100))
print(my_logical)
##   [1] FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE FALSE  TRUE
##  [13]  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE  TRUE FALSE
##  [25] FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE
##  [37] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE
##  [49] FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE
##  [61] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE
##  [73] FALSE  TRUE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE  TRUE FALSE  TRUE
##  [85]  TRUE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE
##  [97]  TRUE FALSE FALSE FALSE
my_letters <- sample(letters)

my_list <- list(my_matrix,my_logical,my_letters)
new_list <- list(my_list[[1]][2,2], my_list[[2]][2], my_list[[3]][2])
typeof(new_list[[1]]) #double
## [1] "double"
typeof(new_list[[2]]) #logical
## [1] "logical"
typeof(new_list[[3]]) #character
## [1] "character"
single_av <- c(new_list[[1]],new_list[[2]],new_list[[3]])
typeof(single_av) #now just a character
## [1] "character"

Question 3

my_unis <- runif(26, min=1, max=10)
my_letters <- sample(LETTERS)
data_frame <- data.frame(my_unis,my_letters)

data_frame[ ,1][sample(nrow(data_frame), 4)] <- NA
is.na(data_frame)
##       my_unis my_letters
##  [1,]   FALSE      FALSE
##  [2,]   FALSE      FALSE
##  [3,]   FALSE      FALSE
##  [4,]   FALSE      FALSE
##  [5,]   FALSE      FALSE
##  [6,]   FALSE      FALSE
##  [7,]   FALSE      FALSE
##  [8,]   FALSE      FALSE
##  [9,]   FALSE      FALSE
## [10,]   FALSE      FALSE
## [11,]   FALSE      FALSE
## [12,]   FALSE      FALSE
## [13,]   FALSE      FALSE
## [14,]   FALSE      FALSE
## [15,]   FALSE      FALSE
## [16,]   FALSE      FALSE
## [17,]    TRUE      FALSE
## [18,]   FALSE      FALSE
## [19,]   FALSE      FALSE
## [20,]    TRUE      FALSE
## [21,]    TRUE      FALSE
## [22,]   FALSE      FALSE
## [23,]   FALSE      FALSE
## [24,]   FALSE      FALSE
## [25,]   FALSE      FALSE
## [26,]    TRUE      FALSE
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
ABC_dataframe <- data_frame %>% arrange(data_frame[2])
print(ABC_dataframe)
##     my_unis my_letters
## 1  2.102428          A
## 2  2.158331          B
## 3  3.198105          C
## 4  7.377216          D
## 5  1.037026          E
## 6  5.076838          F
## 7  7.362733          G
## 8  5.035376          H
## 9  5.509014          I
## 10       NA          J
## 11 6.294616          K
## 12       NA          L
## 13 5.760605          M
## 14 1.244039          N
## 15 8.923814          O
## 16 6.133197          P
## 17 2.105820          Q
## 18 4.048511          R
## 19 7.411266          S
## 20       NA          T
## 21       NA          U
## 22 4.409480          V
## 23 3.705343          W
## 24 3.496684          X
## 25 3.666021          Y
## 26 9.855381          Z
mean(ABC_dataframe[,1],na.rm=TRUE)
## [1] 4.814175