Reputation: 7313
Is there something in R to open a text file? In Python, one could open a text file using notepad:
import subprocess as sp
programName = "notepad.exe"
fileName = "file.txt"
sp.Popen([programName, fileName])
Other methods are described in the post as well. Is there something similar in R?
Upvotes: 2
Views: 1463
Reputation: 18602
Keeping in mind portability issues, i.e. this is specific to Windows, you can use shell.exec
, which will open the file in whatever program is associated with that type of file by default - e.g.
## full path
shell.exec(paste0(c(getwd(), "/tmpfile.txt"),collapse = ""))
## relative to current working directory
shell.exec("tmpfile.txt")
both open tmpfile.txt
in notepad on my machine.
Upvotes: 3