1

I'm used to separating my code in different files, and call those files when needed. I did not manage to call a notebook (.Rmd) with chunks using the source() function.

I can source a notebook, but it will run as a script (.R), working well for functions written as:

test <- table(mydata$M1, mydata$M2FR) test

but returning errors (attempt to use zero-length variable name) for chunks as:

```{r}
test <- table(mydata$M1, mydata$M2FR)
test

```

Is there a way to use source() on a notebook with chunks, or should I design my files without chunks?

zx8754
  • 52,746
  • 12
  • 114
  • 209

1 Answers1

0

You can compile notebooks with

 rmarkdown::render("analysis.R")

But this will not leave the functions in your workspace, as the notebook is self-contained.

mondano
  • 827
  • 10
  • 29