当我尝试从Rnw
RStudio 中的文件编译 PDF 时,我收到以下错误:
加载所需包:knitr
readLines 中的错误(if (is.character(input2)) { :
无法打开连接
调用: knit -> 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")
在控制台中运行不起作用并引发相同的错误。
由于一辉在我上面提到的线程中要求输出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 中的编译 PDFknitr::knit("file.Rnw")
按钮和R 控制台开始编译。
感谢一辉的提示,我发现项目的工作目录不是文件所在的.Rproj
文件夹,而是上一层。考虑到这一点,我可以通过 R 控制台编译文件。
但是我怎样才能解决这个问题,以便我可以使用编译 PDF按钮?