Can R open a file with another program?

This is a bit of a strange question, but I thought that people might be interested here.

Is it possible that R causes the file to open in another program? For example, could you write a command line that will make the music file start playing? A potential application would be that after the model is finished, music will start playing, warning you of the completion of the model.

Thanks for the help!

+7
source share
3 answers

In addition to the system on Windows, at least you can use shell.exec , which will open the file using the application specified in the Windows file associations. For example, shell.exec("file.txt") will open a text file in your favorite text editor, shell.exec("file.mp3") will launch a media player, etc.

+9
source

You can do this by calling the system () function.

+5
source

There is an audio package that allows you to play wave files:

 require(audio) wave_file <- dir("C:/Windows/Media",pattern="\\.wav$")[1] # some random windows wave file f <- load.wave(wave_file) play(f) 
+5
source

All Articles