Here is the example in the help document of function cli::tree
. I works well. And I want to produce the structure in this way.
library(cli)
data <- data.frame(
stringsAsFactors = FALSE,
package = c("processx", "backports", "assertthat", "Matrix",
"magrittr", "rprojroot", "clisymbols", "prettyunits", "withr",
"desc", "igraph", "R6", "crayon", "debugme", "digest", "irlba",
"rcmdcheck", "callr", "pkgconfig", "lattice"),
dependencies = I(list(
c("assertthat", "crayon", "debugme", "R6"), character(0),
character(0), "lattice", character(0), "backports", character(0),
c("magrittr", "assertthat"), character(0),
c("assertthat", "R6", "crayon", "rprojroot"),
c("irlba", "magrittr", "Matrix", "pkgconfig"), character(0),
character(0), "crayon", character(0), "Matrix",
c("callr", "clisymbols", "crayon", "desc", "digest", "prettyunits",
"R6", "rprojroot", "withr"),
c("processx", "R6"), character(0), character(0)
))
)
tree(data)
#> processx
#> ├─assertthat
#> ├─crayon
#> ├─debugme
#> │ └─crayon
#> └─R6
tree(data, root = "rcmdcheck")
#> rcmdcheck
#> ├─callr
#> │ ├─processx
#> │ │ ├─assertthat
#> │ │ ├─crayon
#> │ │ ├─debugme
#> │ │ │ └─crayon
#> │ │ └─R6
#> │ └─R6
#> ├─clisymbols
#> ├─crayon
#> ├─desc
#> │ ├─assertthat
#> │ ├─R6
#> │ ├─crayon
#> │ └─rprojroot
#> │ └─backports
#> ├─digest
#> ├─prettyunits
#> │ ├─magrittr
#> │ └─assertthat
#> ├─R6
#> ├─rprojroot
#> │ └─backports
#> └─withr
Created on 2018-11-18 by the reprex package (v0.2.1)
But when I edit it into a simpler example, I always get such an error.
library(cli)
library(tidyverse)
data.frame(
package = 'processx'
,dependencies = c("assertthat", "crayon", "debugme", "R6") %>% list %>% I
) %>%
tree(root = "rcmdcheck")
#> Error in `[[.default`(labels, num_root): 下标出界
Created on 2018-11-18 by the reprex package (v0.2.1)
I don't know why, and I find there is less examples of cli::tree
online.