Home > Enterprise >  Get a list of directories in R in order
Get a list of directories in R in order

Time:01-23

I'm trying to get a list of directories in R. I ran the following code and I sort of got what I wanted except for one hitch, R didn't list it in order. It shows me a numbered list but in the order of 1,3,5,7 etc and lists two folders beside each other. I want to know how to get a list with one folder name per line. I attached a picture for referenceenter image description here

CodePudding user response:

This is the default in R to print a vector. If you want to format it otherwise, you need to use something like writeLines(list.dirs("c:/"))

# vectror printing
letters[1:10]
#>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"

# formatted printing
writeLines(letters[1:10])
#> a
#> b
#> c
#> d
#> e
#> f
#> g
#> h
#> i
#> j
  •  Tags:  
  • Related