Rnotebook没有显示数据帧的代码输出 [英] Rnotebook not showing code output for data frames

查看:155
本文介绍了Rnotebook没有显示数据帧的代码输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试查看数据帧结果时,Rnotebook中的代码块输出没有出现(好像没有在运行).我必须将其传递给pander()函数才能看到输出打印出来.这和针织物有关吗?之所以提及这一点,是因为我在开始时将选项设置为以下内容:

My code chunk output in Rnotebook is not appearing (as if not being run) when I try to view data frame results. I have to pass it through the pander() function to see the output print out. Is this something to do with knitr? I mention this because I set the options at the beginning to the following:

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, eval = TRUE)
```

我尝试直接在块中设置选项,但得到相同的不需要的结果.是否有我未正确配置的设置?我还必须提到,这是一种不一致的行为.也就是说,我可能会停止工作,过一会儿代码输出就会以某种方式出现.

I have tried setting the options directly in the chunk but get the same unwanted result. Is there a setting I am not configuring correctly? I have to also mention that this is a behaviour that has been somehow inconsistent. That is, I may stop working on it and some time later the code output comes up somehow.

这是我尝试将粘贴复制到Rnotebook的工作代码示例.

Here's an sample of the work code I am trying to run to copy paste into Rnotebook.

设置笔记本工作区选项

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, eval = TRUE)
```

加载相应的库和软件包

```{r}
library(easypackages)
libraries("dplyr",
          "ggplot2",
          "caret",
          "tidyverse",
          "tidytext",
          "ROCR",
          "pander",
          "knitr",
          "broom")
```

以下是一些示例数据:

```{r}
library(readr)
attibm <- read_csv("https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/mtcars.csv", 
    col_types = cols(Attrition = col_character()))
```

看到结构. (此输出显示为预期的结果)

Seeing the structure. (This output is shown as expected)

```{r}
glimpse(attibm)
```

预览前十行(这是未显示的输出.什么也没有发生)

Preview the first ten rows (this is the output that doesn't show. Nothing happens)

```{r}
head(attibm)
```

此输出也不显示. (什么都没发生)

This output doesn't show either. (Nothing happens)

```{r}
attibm %>% 
  summarise_if(is.integer, mean)
```

当我通过Pander函数时,将显示它.

When I pass the pander function THEN it is shown.

```{r}
attibm %>% 
  summarise_if(is.integer, mean) %>% 
  pander()
```

这个也显示了

```{r}
pander(head(attibm))
```

我已经检查了以下问题: R笔记本中数字的输出 ,但是我看不到这种情况的关联.

I have checked the question posted: Output of numbers in R notebook, but I wasn't able to see the connection with this case.

我希望这已经足够清楚了,您可以重现此处显示的代码.在这个问题上的任何帮助将不胜感激.

I hope this is clear enough and that you can reproduce the code shown here. Any help on this issue will be highly appreciated.

推荐答案

markdown的最新版本不再与pandocv2兼容. 您可以使用

The newest version of markdown is no longer compatible with pandocv2. You can check your version of pandoc using

library(rmarkdown); pandoc_version()

如果是pandoc版本,则需要可以下载的markdown开发版本

If it's pandoc version you need the development version of markdown that you can download there

library(devtools); install_github("rstudio/rmarkdown")

要缩小最新版本的pandoc是否存在问题,请尝试通过添加来检查生成的.md是否正确

To narrow down the issue of whether this is a problem with the newest version of pandoc, try checking wether the .md produced is correct by adding

 ---
 output:  
  html_notebook 
    keep_md: true
 ---

这篇关于Rnotebook没有显示数据帧的代码输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆