R/getLoc.R

#' Prompts to ask for the locations of the samples for bulk upload
#' 
#' @param new.df Dataframe after running getRequiredFields
#' @export
#' 
#' @return A bulk upload file template
#' 
#' @examples
#' new.df <- getRequiredFields(df)


getLoc <- function(new.df){
  cohort <- new.df$`Arking Specimen Form#Cohort`
  a <- unlist(strsplit(new.df$`Collection Date`, split = '-'))
  dat.for.lab <- paste0(a[[1]], a[[2]], substr(a[[3]], 3,4))
  
  ask <- readline('What is the column with the box number called? ' )
  boxnumber <- df[,grep(paste0('\\b', ask, '\\b'), colnames(df))]
  
  container <- paste0(cohort, '.', dat.for.lab, '.', boxnumber)
  
  ask <- readline('What is the column with the row info called? ' )
  row <- df[,grep(paste0('\\b', ask, '\\b'), colnames(df))]
  
  ask <- readline('What is the column with the column info called? ' )
  col <- df[,grep(paste0('\\b', ask, '\\b'), colnames(df))]
  
  new.df$Container <- container
  new.df$Row <- row
  new.df$Column <- col
  return(new.df)
}
syyang93/openSpec documentation built on May 16, 2019, 3:24 p.m.