I have multiple Red files that I am joining with bookdown
. This has gone OK until I got the following error message
label: error_chunk
Quitting from lines 2941-2947 (bookdown-demo.Rmd) Error in model.frame.default(formula = glu ~ age, drop.unused.levels = TRUE) : variable lengths differ (found for 'age') Calls: ... lm -> eval -> eval -> -> model.frame.default Execution halted
Exited with status 1.
error_chunk is the following code:-
```{r error_chunk}
sample1 <- data.frame(glu=c(120,130,140,150), age=c(55,60,65,70))
attach(sample1)
#For linear regression analysis, the function lm (linear model) is used
fit<-lm (glu~age)
print(fit)
```
This is straightforward and obviously runs on its own and produces its own Rmd document.
What is occurring in the bookdown
environment?