R/weekYColColsTabs.R

Defines functions weekYColColsTabs

Documented in weekYColColsTabs

#' weekYColColsTabs
#' @param dfNameVec a string or a vector of class character indicating the name(s) of the data.frame object(s) to be used. 
#' @param dfColNameVec a string or a vector of class character indicating the name(s) of the column(s) to be handled. The entries in each of these columns must be dates in the date format "dd.mm.yyyy".
#' @return 
#' the modified data.frame objects which now contain new columns containing the week of the year corresponding to the entries in the respective columns specified by \code{dfColNameVec} of the original data frames. The entries in the new column are integers in the range [1,53]. If 1 January falls on either of Monday, Tuesday, Wednesday, Thursday then it belongs to week 1, otherwise week 53 of the last year. The first week of the year is the one that contains the first Thursday of the year.
#' @description takes as input a vector containing date.frame object names (\code{dfNameVec}), and a vector containing column names (\code{dfColNameVec}) and inserts a new column in each data frame for each column in \code{dfColNameVec} containing the week of the year corresponding to the entries in that column
#' @examples
#' weekYColColsTAbs(c("rice","maize"),c("tillDate","plantDat","hrvDate"))
#' weekYColColsTabs(c("students"),c("start_date","date_of_birth"))
#' weekYColColsTabs("students",c("start_date","date_of_birth"))
weekYColColsTabs<-function(dfNameVec,dfColNameVec)
{
  for (i in dfNameVec)
  {
    for (j in c(dfColNameVec))
    {
      weekYCol(i,j,"%d.%m.%Y")
    }
  }
}
lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.