R/Harvest_trees.R

#' Collect trees from dependency directory
#' @param dependency.dir Directory with dependency files
#' @return data frame of stacked dependency files
#' @details adapts to relative or absolute directories
#' @export
#' @examples 
#'\dontrun{
#' readDependency(pullSourceInfo("adaprHome")$dependency.dir) 
#'} 
#' 
#' 
readDependency <- function(dependency.dir){
  
  #collects all trees in dependency.dir
  
  dep.files <- list.files(dependency.dir,full.names=TRUE)
  
  trees <- NULL
  
  if(length(dep.files)>0){
    
  list.deps <- lapply(dep.files,read.dependency)
  
  trees <- plyr::rbind.fill(list.deps)
    
  project.id <-  list.deps[[1]]$project.id[1] 
  
  new.path <- getProjectPath(project.id)
  
  if(is.na(list.deps[[1]]$project.path[1])){
    
    shaved.variables <- c("path","source.file.path","target.path","project.path")
    
    for(char.shave in shaved.variables){
      
        trees[[char.shave]] <- file.path(new.path,trees[[char.shave]])  
      
    }
    
    return(trees)
    
  }
    
  
  } # if there exist dependency files
  
  
  return(trees)
}

Try the adapr package in your browser

Any scripts or data that you put into this service are public.

adapr documentation built on May 1, 2019, 7:05 p.m.