使用带有ESS的knitR时出错

时间:2015-07-08 06:57:02

标签: r emacs knitr

我搞砸了一些东西,但我不知道在哪里看。我的猜测是,当我在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   

1 个答案:

答案 0 :(得分:2)

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

我按顺序对它们进行了升级,它只在升级后才起作用,所以我怀疑这是罪魁祸首。

叹息,看起来可能是时候更新.packages()。