Run Windows CMD commands from R
2
1
Entering edit mode
5.8 years ago
3335098459 ▴ 30

Hello,

I need to design a function in R that can direct the windows CMD to run a command. The command is:

"copy *.txt combinedfiles.txt"

I used this command

system("cmd.exe copy *.txt combinedfiles.txt")

I am a beginner at R-Studio. So, if this question sounds childish to you please pardon me.

Kindly help me out. Thanks

R genome • 7.0k views
ADD COMMENT
1
Entering edit mode
5.8 years ago
h.mon 35k

Why use a non-portable solution, if R provides you with a portable one:

file.copy( from, to, overwrite = recursive, recursive = FALSE, copy.mode = TRUE, copy.date = FALSE )
ADD COMMENT
0
Entering edit mode
5.8 years ago
zx8754 11k

For Windows try using shell:

shell("copy test1.txt test1_mycopy.txt")

But I agree with @h.mon, and would prefer to use file.copy.

ADD COMMENT

Login before adding your answer.

Traffic: 3555 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6