# no datageneration

Question

In the same topic as previous exercise, list all files in all subfolders in the directory containing the files for the different packages (see command Sys.getenv('R_LIBS_USER')). On average, how many files are needed for each package?

Solution

r_pkg_folder <- Sys.getenv ('R_LIBS_USER')

pkg_files <- list.files(r_pkg_folder, recursive = TRUE)
my_dirs <- list.dirs(r_pkg_folder, recursive = FALSE)

n_files <- length(pkg_files)
n_dirs <- length(my_dirs)

my_msg <- paste0('We have ', length(pkg_files), ' ',
                 'files for ', length(my_dirs), ' packages. \n',
                 'On average, there are ', n_files/n_dirs, ' files per directory.')

message(my_msg)

Meta-information

extype: string exsolution: r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE) exname: "install pkgs" exshuffle: TRUE



msperlin/afedR documentation built on Sept. 11, 2022, 9:49 a.m.