【问题标题】:R Notebooks not evaluating chunksR笔记本不评估块
【发布时间】:2017-05-25 06:55:01
【问题描述】:

我正在尝试 Rstudio 中的新 R 笔记本功能,但未评估这些块。当我预览 rstudio 中的最小示例时(当您启动一个新文件时),窗口明确显示;

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.

但是,预览中没有“运行”按钮,并且代码不会评估。这就是我基本上得到的(即使我将eval = TRUE 放在块选项中)。

我已经完成了,但我仍然无法评估这些块。使用普通的 rmarkdown 文档时,它的评估没有问题。我是否必须放置一个特定的 htmlwidget 或其他东西?

这是我的规格:

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
 [1] tse.sql_0.1.0   memisc_0.99.7-1 MASS_7.3-45     lattice_0.20-34 foreign_0.8-67  magrittr_1.5    ggplot2_2.2.0  
 [8] inegiR_1.2.0    dplyr_0.5.0     tse.utils_0.1.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7      knitr_1.14       munsell_0.4.3    colorspace_1.2-7 R6_2.2.0         stringr_1.1.0    plyr_1.8.4      
 [8] tools_3.3.2      grid_3.3.2       gtable_0.2.0     DBI_0.5-1        htmltools_0.3.5  lazyeval_0.2.0   yaml_2.1.13     
[15] assertthat_0.1   digest_0.6.10    tibble_1.2       formatR_1.4      base64enc_0.1-3  evaluate_0.10    rmarkdown_1.1   
[22] stringi_1.1.2    scales_0.4.1     XML_3.98-1.4     jsonlite_1.1     zoo_1.7-13    

使用 Rstudio 1.0.44 和这些选项:

【问题讨论】:

    标签: r rstudio rnotebook


    【解决方案1】:

    使用 CTRL+SHIFT+Enter 运行代码块。如果您现在预览 R Notebook,代码输出将可用。 代码必须在编辑器中执行才能反映在预览中。

    【讨论】:

      【解决方案2】:

      作为一项功能(或错误),当您单击“预览”时,Notebooks 中的块不会运行,而是在您评估每个块时(在编写 Notebook 本身的过程中)。

      如果您在发布前运行 Notebook 中的所有代码,使用源窗格右上角的“运行”按钮,RStudio 可以找到您想要嵌入的对象。

      或者,您可以单击 Notebook 中每个代码块右上角的绿色播放(向右箭头)来运行每个代码块。

      【讨论】:

      • 嗨,Daisey,谢谢,但它似乎不起作用。即使评估(如左侧)我在右侧得到一个空白页。可能与我的设置有关吗?
      • 嗨@eflores89 当你评估然后点击预览,代码仍然没有发布?你能把这个截图发一下吗?从预览下拉菜单中选择 Knit to HTML 会发生什么?
      猜你喜欢
      • 2017-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      • 1970-01-01
      • 2019-09-17
      相关资源
      最近更新 更多