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












0















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?










share|improve this question


















  • 2





    That's a LaTeX error, because you have the number 1.7191times 10^{}{4}, which needs to be typeset in math mode. Enter the whole inline calculation within $ `r ... `$.

    – user2554330
    Jan 18 at 20:28













  • The escapes might still cause trouble...

    – user2554330
    Jan 18 at 20:29











  • I've tried $`r round(mean(USB_Belegzahlen$'Bettentage DRG'))`$ which kinda works, but give's me the output 1.7191 × 10^4. How can I get it to just return "17181"?

    – Hurlikus
    Jan 20 at 10:30








  • 1





    Just format the result, using sprintf, format, formatC, etc. If you get rid of the math operations like times you won't need the dollar signs.

    – user2554330
    Jan 20 at 11:19






  • 1





    `r sprintf("%.0f", mean(USB_Belegzahlen$'Bettentage DRG'))`

    – user2554330
    Jan 20 at 15:57
















0















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?










share|improve this question


















  • 2





    That's a LaTeX error, because you have the number 1.7191times 10^{}{4}, which needs to be typeset in math mode. Enter the whole inline calculation within $ `r ... `$.

    – user2554330
    Jan 18 at 20:28













  • The escapes might still cause trouble...

    – user2554330
    Jan 18 at 20:29











  • I've tried $`r round(mean(USB_Belegzahlen$'Bettentage DRG'))`$ which kinda works, but give's me the output 1.7191 × 10^4. How can I get it to just return "17181"?

    – Hurlikus
    Jan 20 at 10:30








  • 1





    Just format the result, using sprintf, format, formatC, etc. If you get rid of the math operations like times you won't need the dollar signs.

    – user2554330
    Jan 20 at 11:19






  • 1





    `r sprintf("%.0f", mean(USB_Belegzahlen$'Bettentage DRG'))`

    – user2554330
    Jan 20 at 15:57














0












0








0








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?










share|improve this question














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?







r markdown r-markdown knitr inline-code






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 18 at 18:40









HurlikusHurlikus

608




608








  • 2





    That's a LaTeX error, because you have the number 1.7191times 10^{}{4}, which needs to be typeset in math mode. Enter the whole inline calculation within $ `r ... `$.

    – user2554330
    Jan 18 at 20:28













  • The escapes might still cause trouble...

    – user2554330
    Jan 18 at 20:29











  • I've tried $`r round(mean(USB_Belegzahlen$'Bettentage DRG'))`$ which kinda works, but give's me the output 1.7191 × 10^4. How can I get it to just return "17181"?

    – Hurlikus
    Jan 20 at 10:30








  • 1





    Just format the result, using sprintf, format, formatC, etc. If you get rid of the math operations like times you won't need the dollar signs.

    – user2554330
    Jan 20 at 11:19






  • 1





    `r sprintf("%.0f", mean(USB_Belegzahlen$'Bettentage DRG'))`

    – user2554330
    Jan 20 at 15:57














  • 2





    That's a LaTeX error, because you have the number 1.7191times 10^{}{4}, which needs to be typeset in math mode. Enter the whole inline calculation within $ `r ... `$.

    – user2554330
    Jan 18 at 20:28













  • The escapes might still cause trouble...

    – user2554330
    Jan 18 at 20:29











  • I've tried $`r round(mean(USB_Belegzahlen$'Bettentage DRG'))`$ which kinda works, but give's me the output 1.7191 × 10^4. How can I get it to just return "17181"?

    – Hurlikus
    Jan 20 at 10:30








  • 1





    Just format the result, using sprintf, format, formatC, etc. If you get rid of the math operations like times you won't need the dollar signs.

    – user2554330
    Jan 20 at 11:19






  • 1





    `r sprintf("%.0f", mean(USB_Belegzahlen$'Bettentage DRG'))`

    – user2554330
    Jan 20 at 15:57








2




2





That's a LaTeX error, because you have the number 1.7191times 10^{}{4}, which needs to be typeset in math mode. Enter the whole inline calculation within $ `r ... `$.

– user2554330
Jan 18 at 20:28







That's a LaTeX error, because you have the number 1.7191times 10^{}{4}, which needs to be typeset in math mode. Enter the whole inline calculation within $ `r ... `$.

– user2554330
Jan 18 at 20:28















The escapes might still cause trouble...

– user2554330
Jan 18 at 20:29





The escapes might still cause trouble...

– user2554330
Jan 18 at 20:29













I've tried $`r round(mean(USB_Belegzahlen$'Bettentage DRG'))`$ which kinda works, but give's me the output 1.7191 × 10^4. How can I get it to just return "17181"?

– Hurlikus
Jan 20 at 10:30







I've tried $`r round(mean(USB_Belegzahlen$'Bettentage DRG'))`$ which kinda works, but give's me the output 1.7191 × 10^4. How can I get it to just return "17181"?

– Hurlikus
Jan 20 at 10:30






1




1





Just format the result, using sprintf, format, formatC, etc. If you get rid of the math operations like times you won't need the dollar signs.

– user2554330
Jan 20 at 11:19





Just format the result, using sprintf, format, formatC, etc. If you get rid of the math operations like times you won't need the dollar signs.

– user2554330
Jan 20 at 11:19




1




1





`r sprintf("%.0f", mean(USB_Belegzahlen$'Bettentage DRG'))`

– user2554330
Jan 20 at 15:57





`r sprintf("%.0f", mean(USB_Belegzahlen$'Bettentage DRG'))`

– user2554330
Jan 20 at 15:57












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54259746%2fan-error-occurs-when-trying-to-knit-certain-inline-code-mean-value-calculation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54259746%2fan-error-occurs-when-trying-to-knit-certain-inline-code-mean-value-calculation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Liquibase includeAll doesn't find base path

How to use setInterval in EJS file?

Petrus Granier-Deferre