Is there an easy way to list only non-empty directories?
I know list.dirs , but I could not find a way to list only non-empty directories.
list.dirs
You can use list.files for the result of list.dirs :
list.files
dirlist <- list.dirs("./R/R-3.3.1/library/zoo") dirlist [sapply(dirlist, function(x) length(list.files(x))>0)]
Get the file names, then extract the directory name:
unique(dirname(list.files(full.names = TRUE, recursive = TRUE)))
Here's a one line solution:
nonempty <- list.dirs(recursive=F)[which(lengths(lapply(list.dirs(recursive=F), list.files)) > 0)]
Source: https://habr.com/ru/post/1012190/More articles:How to decrypt encryption using System.Cryptography - c #Xcode 8 ios 10 Simulator, you can send a push notification to the simulator - ios10Where are the ini files on the MacOsX Sierra? - phpOSX - can't find my php.ini - apacheHow to handle reading notifications in the backend of a mobile application - ruby-on-railsSpring Prevention Startup boot failure with couchbase connection error - javaIs there a way to import all partial files into SASS? - cssCreate text with multiple clickable lines - javascriptRCP application cannot start due to OSGi package dependency problem - javaHow to fix content using skew div? - javascriptAll Articles