在 R returns 中使用 Windows CMD 系统命令出现“127”错误
Working with Windows CMD system commands in R returns a "127" error
- 使用 CMD,有效:
"C:\Program Files (x86)\ProteoWizard\ProteoWizard 3.0.21175.5b6d9afee\msconvert.exe" msconvert "C:\Users\Data\QC3.raw" -o "C:\Users\Data"
- 使用 R system() 时,出现“127”错误:
msconvertpath <- c("C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe'")
file <- c("C:/Users/Data/QC1.raw")
outfile <- c("C:/Users/Data")
convert <- paste0(msconvertpath, '"', " msconvert ", '"', file, '"', " -o ", '"', outfile)
system(convert)
非常感谢您的帮助。
检查 R 中的变量:
> msconvertpath
[1] "C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe'"
您可以在最后(关闭双引号之前)看到无效(多余的)单引号,并且
> convert
[1] "C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe'\" msconvert \"C:/Users/Data/QC1.raw\" -o \"C:/Users/Data"
>
您可以看到缺少转义双引号(msconvertpath
左引号,outfile
右引号)。
调整后的代码片段可以工作:
msconvertpath <- c("C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe")
### ^ removed invalid single quote at the very end (before closing double quote)
afile <- c("C:/Users/Data/QC1.raw")
outfile <- c("C:/Users/Data")
convert <- paste0('"', msconvertpath, '"', " msconvert ", '"', afile, '"', " -o ", '"', outfile, '"')
### ^ added missing escaped double quotes
system(convert)
convert
变量看起来 语法 现在可以接受:
> convert
[1] "\"C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe\" msconvert \"C:/Users/Data/QC1.raw\" -o \"C:/Users/Data\""
- 使用 CMD,有效:
"C:\Program Files (x86)\ProteoWizard\ProteoWizard 3.0.21175.5b6d9afee\msconvert.exe" msconvert "C:\Users\Data\QC3.raw" -o "C:\Users\Data"
- 使用 R system() 时,出现“127”错误:
msconvertpath <- c("C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe'")
file <- c("C:/Users/Data/QC1.raw")
outfile <- c("C:/Users/Data")
convert <- paste0(msconvertpath, '"', " msconvert ", '"', file, '"', " -o ", '"', outfile)
system(convert)
非常感谢您的帮助。
检查 R 中的变量:
> msconvertpath
[1] "C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe'"
您可以在最后(关闭双引号之前)看到无效(多余的)单引号,并且
> convert
[1] "C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe'\" msconvert \"C:/Users/Data/QC1.raw\" -o \"C:/Users/Data"
>
您可以看到缺少转义双引号(msconvertpath
左引号,outfile
右引号)。
调整后的代码片段可以工作:
msconvertpath <- c("C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe")
### ^ removed invalid single quote at the very end (before closing double quote)
afile <- c("C:/Users/Data/QC1.raw")
outfile <- c("C:/Users/Data")
convert <- paste0('"', msconvertpath, '"', " msconvert ", '"', afile, '"', " -o ", '"', outfile, '"')
### ^ added missing escaped double quotes
system(convert)
convert
变量看起来 语法 现在可以接受:
> convert
[1] "\"C:/Program Files (x86)/ProteoWizard/ProteoWizard 3.0.21175.5b6d9afee/msconvert.exe\" msconvert \"C:/Users/Data/QC1.raw\" -o \"C:/Users/Data\""