R/Hello_Eagles.R

Defines functions hello_eagles

#'say hello to the EAGLES
#'
#'This function says hello to eagles depending on data
#'
#'@param eagles character , the names of the EAGLES to be greetings
#'@param daytime character, optional ,either "auto"to calculate daytime "morning" or "evening" or ""
#'
#'@return Nothing , it will just say hello 
#'
#'@importFrom lubridate hour
#'@export 

getwd()
#install.packages('RMySQL', repos='http://cran.us.r-project.org')
install.packages('tidyverse',repos='http://cran.us.r-project.org')
install.packages('lubridate',repos='http://cran.us.r-project.org')

library(lubridate)
hello_eagles<-function(eagles,daytime){
  
  
  
  if (daytime=="auto"){ 
    time<-Sys.time()
    time
    
    time_hour<- lubridate::hour(time)
    time_hour
    
    
    if (time_hour<12){
      daytime<-"morning"
    } else if (time_hour>=12 & time_hour<14) {
      daytime<-"day"
    } else if (time_hour>=14 & time_hour<17){
      daytime<-"afternoon"
    } else {
      daytime<-"evening"
    }
  }
  
  if (daytime=="morning"){
    greeting<-"Good Morning,"
  }else if (daytime=="evening"){
    greeting<-"Good Evening,"
  }else if (daytime=="afternoon"){
    greeting<-"Hi,"
  }else {
    greeting<-"Hello,"
  }
  
  cat(paste0(greeting,paste0(eagles,collapse = ", "),"!"))
}
sunymo/SUN documentation built on Nov. 26, 2019, 12:16 a.m.