Report on erroneous code diagnostics in RStudio when searching for sources through a source

I work in RStudio in a simple analysis where I can upload some files using the source command. For example, I have this file with some simple analysis:

analysis.R

 # Settings ---------------------------------------------------------------- data("mtcars") source("Generic Functions.R") # Some work --------------------------------------------------------------- # Makes no sense mtcars$mpg <- CleanPostcode(mtcars$mpg) 

There are some simple functions in the common functions file that I use to display graphs and perform repetitive tasks. For example, the CleanPostcode function used would look like this:

Common Functions .R

 #' The file provides a set of generic functions # String manipulations ---------------------------------------------------- # Create a clean Postcode for matching CleanPostcode <- function(MessyPostcode) { MessyPostcode <- as.character(MessyPostcode) MessyPostcode <- gsub("[[:space:]]", "", MessyPostcode) MessyPostcode <- gsub("[[:punct:]]", "", MessyPostcode) MessyPostcode <- toupper(MessyPostcode) cln_str <- MessyPostcode return(cln_str) } 

When I run the first file, objects are available in the global environment:

Global environment

There is another function in the file, but they are not related to the described problem.

However, RStudio considers the object inaccessible in scope, as shown by the yellow triangle next to the code:

problem

Question

Is there a way to make RStudio stop doing this. Maybe something has changed with the source command? I tried local = TRUE and got the same. The code works without problems, I just find it annoying.


The report was generated in version 0.99.491 of RStudio.

+6
source share

All Articles