R Markdown在未找到继承(x," list)对象时出错

时间:2017-08-31 15:50:23

标签: r r-markdown

早上好! 在一个R Markdown块中,我试图用kable在rmarkdown中吐出一个表。这是我的虚拟数据:

whytheerror <- data.frame(name=c('school1','school2','school3','school4','school5','school6','school7','school8','school9','school10','school11'), count=c(13,25,36,44,58,63,76,85,93,78,101), percent=c(.7,.6,.2,.32,.41,.44,.97,.02,.31,.5,.11), other_count=c(15,111,33,74,19,5,3,111,1,37,501), other_percent=c(.4,.6,.3,.39,.45,.5,.02,.4,.06,.64,.11))

这是我的代码:

```{r echo = FALSE, results = 'asis'}
kable(whytheerror [1:12, ], caption = "Respondent Breakdown")
```

,错误如下:

Error in inherits(x,"list"): object 'whytheerror ' not found calls: <Anonymous>...withCallingHandlers -> withVisible  -> eval  -> eval  -> kable  -> inherits

我很难弄清楚这个错误意味着什么,而不是修复它。有人可以协助其中一个或两个?

谢谢

1 个答案:

答案 0 :(得分:0)

---
title: "Test"
output: html_document
---

```{r}
whytheerror <- data.frame(name=c('school1','school2','school3','school4','school5','school6','school7','school8','school9','school10','school11'), count=c(13,25,36,44,58,63,76,85,93,78,101), percent=c(.7,.6,.2,.32,.41,.44,.97,.02,.31,.5,.11), other_count=c(15,111,33,74,19,5,3,111,1,37,501), other_percent=c(.4,.6,.3,.39,.45,.5,.02,.4,.06,.64,.11))
```

```{r echo = FALSE, results = 'asis'}
library(knitr)
kable(whytheerror[1:11, ], caption = "Respondent Breakdown")
```

产生

enter image description here

没有错误。