I am Creating Web Application with Plumber API in R. I was trying to change the working directory using plumber.
Currently the file is in C:/xampp/htdocs/testMDA
i was trying to change the directory with C:\fileUpload\abc
. abc is passed as argument in function
library(plumber)
#* @get /string
getString <- function(get = ""){
dir <- setwd(file.path("C:/fileUpload/", get))
print(dir)
}
and output i get this which is current directory
"C:/xampp/htdocs/testMDA"
Try to avoid naming arguments like base functions (get in your function). I don't see where you use plumber in your example. What happens if you run the following code (assuming the folder "fileUpload" exists)? If it runs, you can insert it into your function.
dir <- file.path("C:/fileUpload/", "abc")
setwd(dir)
getwd()
my question itself has answer. Think is that In plumber directory gets change to C:\fileUpload\abc
but plumber won't show this instead plumber print its working directory where it is running.
Let's see what is happening!
When plumber is running. It is running in its root folder it will print its root full path. It does change the directory in plumber swagger
but won't print getwd
. My Aim is to change the directory.
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.