How to use Linux commands in R

cli
linux

#1

Greetings,
I would like to run several linux commands from within an R script, actually notebook. The reason for doing this is mainly for educational purposes. I would like capture the linux commads that would be normally used...

I know it seems like a noobie question but a quick search came up with nada.
I am considering: tar, bzip2, gz, But what commands would 'you' suggest to replace them?


#2

Take a look at ?system and ?system2 commands in R. I'm fairly certain they do what you want.


#3

Thank you M.
Will do.


#4
a = system("echo This_is_the_output", intern = TRUE)
a
# [1] "This_is_the_output"

Hope it helps :slightly_smiling_face:


#5

Thanks for the example, Leon.
I appreciate it!


#6

YW - It this solves your question, please mark it as a solution :slightly_smiling_face:


#7

I didn't notice that you specifically after archiving commands. In that case there are also ?zip and ?tar commands in base R that will most likely cover your use-case.