R/reorder_data.R

Defines functions data_ordered

#'reorder data by individual ID and timestamp
#'
#'@param x a data frame
#'@param y individual local identifier column
#'@param z timestamp column
#'@return product of reordered data frame
#'@export

data_ordered <- function(x, y, by_col){
  x <- x %>%
    rename(ID = {{y}}) %>% 
    rename(sortkey = {{by_col}})
  product <- x[with(x, order(ID, sortkey)),]
  
  if(is.data.frame(product) == FALSE){
    return("ERROR - non data frame")
  }
  return(product)
  
}
MicaelaP24/R_Package_Pineda documentation built on Dec. 17, 2021, 4:14 a.m.