简体   繁体   中英

How to set the working directory in a recently created folder in R?

I have this code to create a new folder with today's date.

 #Get working directory
systempath <- getwd()

#create a file with today's Date
dir.create(file.path(systempath, format(Sys.time(), "%F")))

Now, I would like to write a piece of code to set the working directory in the new file created. I tried this and many other things but it does not work.

setwd(paste0(getwd(), paste0("/", Sys.Date())))

Can you help me?

Ok, found out.:!! There were a stupid "/" missing in the end on the file path. What worked : setwd(paste0(getwd(), paste0("/", Sys.Date(), "/")))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM