Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create subdirectories inside a directory at once in R

I've been looking in SO for a thread about how to create two (or n) subdirectories in a directory at once in R and only found this which it's not quiete what I want.

I can do it in two lines by doing:

dir.create(file.path(getwd(), "test"))

sapply(letters[1:2], 
   function(x) dir.create(file.path(getwd(), "test", paste0(x, "_test"))))

#   a    b 
#TRUE TRUE 

How can I do it in one line?

Thank you.

like image 430
patL Avatar asked Dec 19 '25 12:12

patL


1 Answers

dir.create(file.path(getwd(), 'test'), recursive = TRUE)

like image 122
Abdellatif GOU-ALI Avatar answered Dec 22 '25 02:12

Abdellatif GOU-ALI



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!