R/depreciated/tree.R

Defines functions tree

#' Display the directory tree
#'
#' This function helps users to get the directory tree structure.
#'
#' @param  path The directory you want to dig.
#' @param  ignore ignore the directory in regular expression, by default, 'git'
#' @return data.frame
#' @author Jiaxiang Li
#'
#' @importFrom stringr str_subset
#' @import tibble
#' @importfrom dplyr filter mutate
#' @import data.tree
#' @export

tree <- function(path='.',ignore='git'){
    list.dirs(path) %>%
        tibble::as_tibble() %>%
        dplyr::filter(!value %in% stringr::str_subset(value,ignore)) %>%
        dplyr::mutate(pathString = value) %>%
        # 必须按这个命名,as.Node()才能识别
        # mutate(info = map_dbl(value,file.size))
        # 之后再考虑加功能
        data.tree::as.Node()
}
JiaxiangBU/add2md documentation built on Jan. 31, 2020, 7:46 p.m.