简体   繁体   中英

Setting Directory of command prompt

I would like to set the working directory of the command prompt using the function system2 in R and I got the following error:

system2("cmd.exe", args = paste("cd", "Users/AKatherine/Downloads", sep = " "))

'Akatherine' is not recognized as an internal or external command, operable program or batch file.

Also, I tried to run this

system2("cmd.exe", args = "java -mx150m -cp "*;" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "penn,typedDependencies" -outputFormatOptions "basicDependencies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ./Test/input.txt")

and got the following error:

Error: unexpected ';' in "system2("cmd.exe", args = "java -mx150m -cp "*;"

Do anyone know why? Can anyone help me with this?

For the second part of my question, I tried using the shell function instead of the system2 function and I got the same output that I observe when I type in the same command in the command prompt. I used:

shell(cmd = "java -mx150m -cp \"*;\" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat \"penn,typedDependencies\" -outputFormatOptions \"basicDependencies\" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ./Test/input.txt", shell = "cmd.exe") 

instead of

system2("cmd.exe", args = "java -mx150m -cp \"*;\" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat \"penn,typedDependencies\" -outputFormatOptions \"basicDependencies\" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ./Test/input.txt")

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