Given a root absolute directory path. How do I generate a dendrogram object of all path's below it so that I can visualize the directory tree with R?
Suppose the following call returned the following leaf nodes.
list.files(path, full.names = TRUE, recursive = TRUE
)
root/a/some/file.R
root/a/another/file.R
root/a/another/cool/file.R
root/b/some/data.csv
root/b/more/data.csv
I'd like to make a plot in R like the output of the unix tree
program:
root
├── a
│?? ├── another
│?? │?? ├── cool
│?? │?? │?? └── file.R
│?? │?? └── file.R
│?? └── some
│?? └── file.R
└── b
├── more
│?? └── data.csv
└── some
└── data.csv
It would be especially useful if the solution involved decomposing the file system tree into two data.frame
's:
- a table of nodes (with which I could include attributes such as modification date)
- and a table of edges (also with attributes)
And then building the dendrogram object from those two data.frame
s.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…