简体   繁体   中英

Can I invoke linux shell commands in a R session?

I am using RStudio and at times I want to remove some files in the working directory (eg, previously generated .csv files).

It is quite inconvenient to frequently switch to bash and execute rm . Is there any way of invoking commands in the R console?

See here Use system (or shell) as agstudy's comment says

eg system("pwd")

If you are just removing files, rather than executing arbitrary commands on the shell, you would be better off following Thomas's suggestion:

?file.remove

Using this function instead of shell("rm example.csv") is safer and more portable.

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