在RStudio中编译.Rnw文件出错:项目路径问题?

时间:2017-06-07 07:00:56

标签: r rstudio knitr rnw

当我尝试从RStudio中的Rnw文件编译PDF时,收到以下错误:

  

加载必需的包:knitr

     

readLines中的错误(if(is.character(input2)){:

     

无法打开连接

     

通话:编织 - > readlines方法

     

另外:警告信息:

     

在readLines中(if(is.character(input2)){:

     

无法打开文件' Rnw_test.Rnw':没有这样的文件或目录

     

执行暂停

这只发生在我的办公室电脑上,而不是在家里,所以我认为Rnw文件本身没有问题。

我的问题似乎与此问题相同:https://stackoverflow.com/questions/16826153/error-when-compiling-pdf-using-knitr-in-rstudio#=。但是我的Rprofile没有改变,所以不幸的是,这没有用。

此外,在控制台中运行knitr::knit("file.Rnw")不起作用并抛出相同的错误。

由于Yihui在我上面提到的帖子中询问as.list(Sys.getenv());str(x[grep('^L[AC]',names(x))])的输出,这里是:

$ALLUSERSPROFILE
[1] "C:\\ProgramData"

$APPDATA
[1] "C:\\Users\\user\\AppData\\Roaming"

$BS
[1] "w7"

$CACHE
[1] "C:\\Cache"

$CommonProgramFiles
[1] "C:\\Program Files\\Common Files"

$`CommonProgramFiles(x86)`
[1] "C:\\Program Files (x86)\\Common Files"

$CommonProgramW6432
[1] "C:\\Program Files\\Common Files"

$COMPUTERNAME
[1] "NAME"

$ComSpec
[1] "C:\\Windows\\system32\\cmd.exe"

$DEFLOGDIR
[1] "C:\\ProgramData\\McAfee\\DesktopProtection"

$DISPLAY
[1] ":0"

$FP_NO_HOST_CHECK
[1] "NO"

$GFORTRAN_STDERR_UNIT
[1] "-1"

$GFORTRAN_STDOUT_UNIT
[1] "-1"

$HOME
[1] "//HomedirFiler06.office.in.company.de./homedirs06$/user/Eigene Dateien"

$HOMEDRIVE
[1] "U:"

$HOMEPATH
[1] "\\"

$HOMESHARE
[1] "\\\\HomedirFiler06.office.in.company.de.\\homedirs06$\\user"

$IEVersion
[1] "11"

$KEYFILELOCATION
[1] "C:\\Users\\user\\AppData\\Local\\IBM\\Notes\\Data"

$LG
[1] "de"

$LOCALAPPDATA
[1] "C:\\Users\\user\\AppData\\Local"

$LOGONSERVER
[1] "\\\\M913DCRWI102P"

$NUMBER_OF_PROCESSORS
[1] "2"

$OS
[1] "Windows_NT"

$PATH
[1] "C:\\Program Files\\R\\bin\\x64;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C    :\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\idmu\\common;C:\\Windows\\System3    2\\Windows System Resource Manager\\bin;;C:\\Program Files (x86)\\IBM\\Notes;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\Program     Files\\SAS\\Secure\\ccme4;C:\\Program Files\\SAS\\x86\\Secure\\ccme4;C:\\Users\\user\\AppData\\Local\\IBM\\Notes\\Data"

$PATHEXT
[1] ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"

$PROCESSOR_ARCHITECTURE
[1] "AMD64"

$PROCESSOR_IDENTIFIER
[1] "Intel64 Family 6 Model 60 Stepping 3, GenuineIntel"

$PROCESSOR_LEVEL
[1] "6"

$PROCESSOR_REVISION
[1] "3c03"

$ProgramData
[1] "C:\\ProgramData"

$ProgramFiles
[1] "C:\\Program Files"

$`ProgramFiles(x86)`
[1] "C:\\Program Files (x86)"

$ProgramW6432
[1] "C:\\Program Files"

$PSModulePath
[1] "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\"

$PUBLIC
[1] "C:\\Users\\Public"

$R_ARCH
[1] "/x64"

$R_COMPILED_BY
[1] "gcc 4.9.3"

$R_DOC_DIR
[1] "C:/PROGRA~1/R/doc"

$R_HOME
[1] "C:/PROGRA~1/R"

$R_LIBS_USER
[1] "//HomedirFiler06.office.in.company.de./homedirs06$/user/Eigene Dateien/R/win-library/3.3"

$R_USER
[1] "//HomedirFiler06.office.in.company.de./homedirs06$/user/Eigene Dateien"

$RMARKDOWN_MATHJAX_PATH
[1] "C:/Program Files/RStudio/resources/mathjax-23"

$RS_LOCAL_PEER
[1] "\\\\.\\pipe\\38725-rsession"

$RS_RPOSTBACK_PATH
[1] "C:/Program Files/RStudio/bin/rpostback"

$RS_SHARED_SECRET
[1] "63341846741"

$RSTUDIO
[1] "1"

$RSTUDIO_MSYS_SSH
[1] "C:/Program Files/RStudio/bin/msys-ssh-1000-18"

$RSTUDIO_PANDOC
[1] "C:/Program Files/RStudio/bin/pandoc"

$RSTUDIO_SESSION_PORT
[1] "38725"

$RSTUDIO_USER_IDENTITY
[1] "user"

$SESSIONNAME
[1] "Console"

$SNC_LIB
[1] "C:\\Program Files (x86)\\SAP\\FrontEnd\\SecureLogin\\lib\\sapcrypto.dll"

$SNC_LIB_64
[1] "C:\\Program Files\\SAP\\FrontEnd\\SecureLogin\\lib\\sapcrypto.dll"

$SSF_LIBRARY_PATH
[1] "C:\\Program Files (x86)\\SAP\\FrontEnd\\SecureLogin\\lib\\sapcrypto.dll"

$SSF_LIBRARY_PATH_64
[1] "C:\\Program Files\\SAP\\FrontEnd\\SecureLogin\\lib\\sapcrypto.dll"

$SystemDrive
[1] "C:"

$SystemRoot
[1] "C:\\Windows"

$TEMP
[1] "C:\\Users\\user\\AppData\\Local\\Temp"

$TMP
[1] "C:\\Users\\user\\AppData\\Local\\Temp"

$UATDATA
[1] "C:\\Windows\\CCM\\UATData\\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77"

$UEM_BV
[1] "870"

$USERDNSDOMAIN
[1] "IN.company.DE"

$USERDOMAIN
[1] "IN"

$USERDOMAIN_ROAMINGPROFILE
[1] "IN"

$USERNAME
[1] "user"

$USERPROFILE
[1] "C:\\Users\\user"

$VSEDEFLOGDIR
[1] "C:\\ProgramData\\McAfee\\DesktopProtection"

$windir
[1] "C:\\Windows"

$windows_tracing_flags
[1] "3"

$windows_tracing_logfile
[1] "C:\\BVTBin\\Tests\\installpackage\\csilogfile.log"

$officerFlexBackupSpeicher
[1] "\\\\profilserver03.in.company.de\\profile_backup$\\user"

$officerFlexSpeicher
[1] "\\\\profilserver02.in.company.de\\profile_flex$\\user"

这是我的sessionInfo()

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] magrittr_1.5  tools_3.3.3   stringi_1.0-1 knitr_1.15.1  stringr_1.1.0 evaluate_0.10

任何想法可能出错?

编辑:有关编译的详细信息

我通过RStudio中的编译PDF 按钮以及R控制台中的knitr::knit("file.Rnw")开始编译。

感谢Yihui的提示我认为项目的工作目录不是.Rproj文件所在的文件夹,而是上面一层。考虑到这一点,我可以通过R控制台编译该文件。

但是我如何解决这个问题,以便我可以使用编译PDF 按钮?

0 个答案:

没有答案