An error occurs when trying to knit certain inline code (mean value calculation)

时间:2019-01-18 18:40:19

标签: r markdown r-markdown knitr inline-code

I've run into a problem when I've tried to do some calculations with inline code in Markdown.

Sample:

```{r, echo=FALSE}
"Monat" <- c("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")
"Belegzahlen OFS" <- c(3195, 3020, 3461, 3152, 3095, 3178, 3046, 3073, 2946, 3226, 3231, 3099)
"Bettentage DRG" <- c(14012, 16223, 19419, 17063, 17841, 17891, 16663, 17794, 16144, 18439, 17531, 17275)

USB_Belegzahlen <- as.data.frame(Monat)
USB_Belegzahlen$`Belegzahlen OFS` <- `Belegzahlen OFS`
USB_Belegzahlen$`Bettentage DRG` <- `Bettentage DRG`
```


This is my first calculation `r round(mean(USB_Belegzahlen$'Entlassungen OFS'))`, my second `r round(sd(USB_Belegzahlen$'Entlassungen OFS'))`, my third `r round(sd(USB_Belegzahlen$'Bettentage DRG'))` and my fourth `r round(mean(USB_Belegzahlen$'Bettentage DRG'))`.

Now, all calculations work except for the 4th one. When trying to knit it, it returns this error:

enter image description here

As soon as I delete this last calculation, the code knits fine. Also I'd like to add, that when I run the code in the document it self (control+enter), the results show up fine.

Does anybody know what to do to solve this?

0 个答案:

没有答案