I have a simple script file called test.R
. It\'s saved in the working directory. When I go to File > Open > test.R
, it opens the file in the edit
Another alternative is the shell.exec function.
shell.exec("text.R")
# This will open the file or URL using the path associated with it
Also, I think for your use case. This code snippet might be a little bit useful.
file <- "example.csv"
sub_dir <- "subdirectory"
dir.create(sub_dir)
writeLines("myfile",file.path(sub_dir, file))
# Works
shell.exec(file.path(sub_dir, file, fsep = "\\"))
shell.exec(file.path(sub_dir, file))