I created a simple one data.treeby importing the folder structure with the files inside it.
if (!require("pacman")) install.packages("pacman")
pacman::p_load_gh("trinker/pathr")
library(pathr)
library(data.tree)
folder_structure <- pathr::tree(path = "/Users/username/Downloads/top_level/",
use.data.tree = T, include.files = T)
Now I would like to convert the object folder_structureto data.framewith one row in each folder and a column that determines how many files each folder contains. How can i do this?
For example, I have this very simple folder structure:
top_level_folder
sub_folder_1
file1.txt
sub_folder_2
file2.txt
The answer to the question will require the creation of a conclusion that looks like this:
Folders Files
top_level_folder 0
sub_folder_1 1
sub_folder_2 1
list.dirs("/Users/username/Downloads/top_level/"), , . , , , (.. top_level_folder 0, top_level_folder 2 ).
, , Rails: https://github.com/rails/rails/archive/master.zip Rails .