Thaler,Thorn,LAUSANNE,Applied Mathematics
2013-Oct-24 13:13 UTC
[R] Use R to plot a directory tree
Dear all, I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. Any ideas on that? I was googling a lot but apparently I did not use the right terms ("R tree folder" or "R tree directory" takes me mainly to pages about the "R-tree" a structure for spatial access methods [at least I learnt something new ;)]) Any pointer to the right function is highly appreciated. Cheers, Thorn Thaler NRC Lausanne Applied Mathematics
A wild guess -- take a look at the CRAN "phylohenetics" task view, as that sounds like the sort of thing that might have tree generation and manipulation functions. ... but you may do better with some non-R tool out there. (Hopefully, you'll get a better response, though). Cheers, Bert On Thu, Oct 24, 2013 at 6:13 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics <Thorn.Thaler at rdls.nestle.com> wrote:> Dear all, > > I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. > > Any ideas on that? I was googling a lot but apparently I did not use the right terms ("R tree folder" or "R tree directory" takes me mainly to pages about the "R-tree" a structure for spatial access methods [at least I learnt something new ;)]) > > Any pointer to the right function is highly appreciated. > > Cheers, > > Thorn Thaler > NRC Lausanne > Applied Mathematics > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374
On 10/24/2013 9:13 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics wrote:> Dear all, > > I was wondering whether (or better: how) I can use R to read recursively a directory to get all the sub-folders and files located in the root folder and put it into a tree like structure where the leaves are files and intermediate nodes are the directories? The idea is that I'd like to plot the structure of a certain root folder to be able to restructure the file system. > > Any ideas on that? I was googling a lot but apparently I did not use the right terms ("R tree folder" or "R tree directory" takes me mainly to pages about the "R-tree" a structure for spatial access methods [at least I learnt something new ;)]) > > Any pointer to the right function is highly appreciated. >In addition, or instead of, suggestions for plotting a file structure as a tree, you might consider a treemap (package of same name), which was designed to show this more compactly, using nested rectangles showing, e.g., file sizes or other attributes. HTH -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA