【问题标题】:Error while using knitR with ESS将 knitR 与 ESS 一起使用时出错
【发布时间】:2015-07-08 06:57:02
【问题描述】:

我搞砸了一些东西,但我不知道去哪里找。我的猜测是当我更新emacs 中的一些包时发生了一些事情,但我不知道到底是哪一个。任何帮助将不胜感激即使运行如下基本命令:

\begin{document}
<<test>>=
1+1
@ 
\end{document}

产生以下错误

label: test
Quitting from lines 39-40 (/tmp/tmp.rnw) 
Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 3, 0
In addition: Warning messages:
1: In is.na(res[, 1]) :
  is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(res) : is.na() applied to non-(list or vector) of type 'NULL'

这是堆栈跟踪:

+ Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 3, 0

---------------------------------- 

22: stop(gettextf("arguments imply differing number of rows: %s", 
        paste(unique(nrows), collapse = ", ")), domain = NA)
21: data.frame(..., check.names = FALSE)
20: cbind(deparse.level, ...)
19: cbind(z[, c("line1", "col1", "line2", "col2", "text")], merge_cmd(z, 
        markup))
18: (if (fallback) hi_naive else hilight_one)(code, format, markup, 
        escape_fun)
17: highr::hilight(x, format, prompt = options$prompt, markup = opts$markup)
16: hilight_source(x, "latex", options)
15: (knit_hooks$get("source"))(src, options)
14: wrap.source(X[[1L]], ...)
13: FUN(X[[1L]], ...)
12: lapply(x, wrap, options)
11: wrap.list(res, options)
10: wrap(res, options)
9: unlist(wrap(res, options))
8: block_exec(params)
7: call_block(x)
6: process_group.block(group)
5: process_group(group)
4: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
       error = function(e) {
           setwd(wd)
           cat(res, sep = "\n", file = output %n% "")
           message("Quitting from lines ", paste(current_lines(i), 
               collapse = "-"), " (", knit_concord$get("infile"), 
               ") ")
       })
3: process_file(text, output)
2: knit(input, output = output, envir = envir, quiet = quiet, encoding = encoding)
1: knit2pdf("tmp.rnw")

更新

   ## R version 3.1.2 (2014-10-31)
## Platform: x86_64-redhat-linux-gnu (64-bit)

## locale:
##  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
##  [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
##  [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   
##  [7] LC_PAPER=en_US.utf8       LC_NAME=C                
##  [9] LC_ADDRESS=C              LC_TELEPHONE=C           
## [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

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

## other attached packages:
## [1] knitr_1.10.5

## loaded via a namespace (and not attached):
## [1] compiler_3.1.2 evaluate_0.7   formatR_1.2    highr_0.5      stringr_1.0.0 
## [6] tcltk_3.1.2    tools_3.1.2   

【问题讨论】:

  • sessionInfo()?所有软件包都是最新的吗?
  • @Yihui 我已经更新了内置包并将我的 sessionInfo() 放在上面。但问题仍然存在。你有没有导致问题?
  • @Yihui 更新软件包并重新启动会话解决了问题。非常感谢。

标签: r emacs knitr


【解决方案1】:

今天遇到了同样的问题。对我来说,这是通过将 knitr 包从 1.10.5 版升级到 1.11 版、将评估包从 0.7 版升级到 0.7.2 版、将 formatR 包从 0.9 版升级到 1.2 版以及从 0.2 版升级到更高版本来解决的。 1 到 0.5 版。

我按顺序升级了这些,它只有在升级更高之后才起作用,所以我怀疑这是罪魁祸首。

唉,看来是时候更新.packages()了。

【讨论】:

  • 我可以确认 knitr 1.11 存在问题,并且至少有一个版本低于 0.5.1。但是在将更高版本升级到 0.5.1 后,问题就消失了(使用 knitr 1.1 和 R 3.2.2)
  • 当我将 knitr1.4.1 更新到版本 1.12 时出现同样的问题。从0.2 升级highr0.5.1 时解决。
猜你喜欢
  • 2017-03-03
  • 2018-07-12
  • 2013-01-18
  • 1970-01-01
  • 1970-01-01
  • 2013-04-16
  • 2016-11-05
  • 2021-12-06
  • 2015-07-15
相关资源
最近更新 更多