[R] How to do platform independent system calls?

Asis Hallab asis.hallab at gmail.com
Tue Apr 2 11:42:01 CEST 2013


Dear R experts,

I hope everyone has had a happy easter break.

Recently my work included writing R function that need to call external tools.
I did this using R's system function for example:

system( paste( 'tool', '-input', path_to_input, '-output',
path_to_output, '-other_switch', some_val ) )

I have two question about this:

1) Is there a way to implement such calls to external tools, so they
become platform independent? I mean, so that these calls will work
both on a *nix and a Windows system?

2) Is there a way to generate platform independent paths? So that
"path/2/input.tbl" on *nix systems becomes "path\2\input.tbl" on a
Windows system?

Your help will be much appreciated!
Kind regards!



More information about the R-help mailing list