When using bookdown in RStudio (though I suspect this problem will exist elsewhere, too), it's customary not necessarily to call library(foo) in the same *.Rmd as some function foo::bar() therein.
Erroneously, RStudio (aka. lintr) will then lint foo::bar() as:
no symbol named 'bar()' in scope
Though when run through bookdown (which the repository and RStudio "know") with the default "Merge-Then-Knit" strategy, there is, in fact no problem.
This is a bit annoying when editing a bookdown, and I'm wondering whether this could be fixed in lintr by somehow scoping all *.Rmds inside a project.
@verenakasztantowicz had the same issue.
Hoping this is the right place, and it's not an RStudio or bookdown issue.
MWE (sort of, not a fully-fledge bookdown, but I hope you get the idea)
Let's have an index.Rmd like so:
---
title: "A not so minimal not so working example"
author: "Calvin, Hobbes the Tiger"
site: bookdown::bookdown_site
---
```{r preamble, echo=FALSE, include=FALSE}
library(ggplot2)
```
```{r test-in-index}
ggplot("foo")
```
This lints just fine:
Try the same thing in first-chapter.Rmd, in the same repository and at root and no such luck:
When using
bookdown
in RStudio (though I suspect this problem will exist elsewhere, too), it's customary not necessarily to calllibrary(foo)
in the same*.Rmd
as some functionfoo::bar()
therein. Erroneously, RStudio (aka.lintr
) will then lintfoo::bar()
as:Though when run through
bookdown
(which the repository and RStudio "know") with the default "Merge-Then-Knit" strategy, there is, in fact no problem.This is a bit annoying when editing a bookdown, and I'm wondering whether this could be fixed in
lintr
by somehow scoping all*.Rmd
s inside a project.@verenakasztantowicz had the same issue.
Hoping this is the right place, and it's not an RStudio or bookdown issue.
MWE (sort of, not a fully-fledge bookdown, but I hope you get the idea)
Let's have an
index.Rmd
like so:This lints just fine:
Try the same thing in
first-chapter.Rmd
, in the same repository and at root and no such luck: