简体   繁体   中英

R : Path separator issues when invoking a command with system()

I'd like to invoke these commands in R

path1 <- "C:/folder1"
path2 <- "C:/folder2" 
command <- paste( "xcopy", path1, path2, "/e /i /h", sep=" " )
command
system(command)

The problem is R use / instead of \\ as path separator and I obtain this error :

 Invalid numbers of parameters 

If I execute manually this command in replacing / by \\ then it works

How can I do to manage this problem ?

Thanks

Try this worked for me

path1 <- "F:\\\\folder1"
path2 <- "F:\\\\folder2" command <- paste( "xcopy", path1, path2, "/e /i /h", sep=" " ) command system(paste( 'xcopy', path1, path2, '/e /i /h', sep=" " ))

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