Apharlef
Apharlef

Reputation: 25

Inline code in R Markdown is not executed

I have a r chunk in my markdown document and would like to refer to it via inline code in my text. However, when I want to knit the file, I get an error and the markdown document stops.

data <- as.data.frame(data)
describe(data[,"age"])

hist(as.numeric(data[,"age"]))

mean_age <- mean(data$age)

data$gender <- factor(data$gender, levels = 1:4, labels = c("Female","Male", "Prefer not to answer", "Another gender"))
summary(data[,"gender"]) # table(data$gender)

Here's the inline code:

The mean age of the participants was `r mean_age`. Lorem ipsum etc.

The error ist:

Quitting from lines 168-177 (Seminar_Report.Rmd) Fehler in data$age : Objekt des Typs 'closure' ist nicht indizierbar Ruft auf: ... withVisible -> eval_with_user_handlers -> eval -> eval -> mean Zusätzlich: Warnmeldung: In do_once((if (is_R_CMD_check()) stop else warning)("The function xfun::isFALSE() will be deprecated in the future. Please ", : The function xfun::isFALSE() will be deprecated in the future. Please consider using base::isFALSE(x) or identical(x, FALSE) instead.

The data is referencing to a sample df where age is one column with natural numbers.

Upvotes: 0

Views: 260

Answers (0)

Related Questions