Run Windows CMD commands from R
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
• 7,741 views
•
link
2 answers
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 )
• 1 views
•
link
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.
• 1 views
•
link
Log in to answer this question.