1. Write two functions. These functions should take a numeric vector as input, and determine the mean and the median from the values in the vector. Please do not use the built-in mean() or median() functions. You should also provide some code that initializes your numeric vector and calls your two functions.

my_mean <- function(numVec) {
  my_sum <- 0
  total_nums <- 0
  
  for (i in 1:length(numVec)) {
    if (!is.na(numVec[i])) {
      my_sum <- my_sum + numVec[i]
      total_nums <- total_nums + 1
    }
  }
  return (my_sum / total_nums)
}

my_mean(c(1:20))
## [1] 10.5
my_mean(c(1:10, NA))
## [1] 5.5
my_median <- function(numVec) {
  #Remove NA values
  vec_no_NA <- numVec[!is.na(numVec)]
  
  #Sort vector
  sort(vec_no_NA)
  
  #Get length of vector
  n <- length(vec_no_NA)

  if(n == 0) {
    return(NA)
  } else if (n == 1) {
    return(vec_no_NA[1])
  } else if (n %% 2 == 1) {
    return(vec_no_NA[ceiling(n / 2)])
  } else {
    return(my_mean(c(vec_no_NA[n / 2], vec_no_NA[n / 2 + 1])))
  }
}
my_median(c(1,1,1,2,3,4,4,4,NA,NA,NA))
## [1] 2.5
my_median(c(NA))
## [1] NA
my_median(1:20)
## [1] 10.5
my_median(1:21)
## [1] 11
my_median(1)
## [1] 1