##############################################
#  Writing functions
##############################################

## --------------------------------------------------------------------------------------------------------------------------------------------------
My_sqrt <- function(x) {
  sqrt(x)
}

# use the function
My_sqrt(12)

## --------------------------------------------------------------------------------------------------------------------------------------------------
My_sqrt <- function(x, print_info = TRUE) {
  y <- sqrt(x)
  if (print_info) {
    print(paste("sqrt", x, "equals", y))
  }
  return(y)
}

# some calls of the function
My_sqrt(16)
My_sqrt(16, FALSE)
My_sqrt(16, TRUE)

## --------------------------------------------------------------------------------------------------------------------------------------------------
My_sqrt(c(16, 36, 64))
My_sqrt(c(16, 36, 64), FALSE)


## Your Turn!
## --------------------------------------------------------------------------------------------------------------------------------------------------






My_mean_SD <- function(x, med = FALSE) {
   mean_x <- ...
   stdv_x <- ...
   cat("Mean is:", ... , ", SD is:", ... , "\n")
 
   if(...){
     median_x <- ...
     cat("Median is:", ... , "\n")
   }
 }


## --------------------------------------------------------------------------------------------------------------------------------------------------
