2

When I use following snippet in my .Rprofile file of a project:

.env <- new.env()

.env$test <- function() {
  print("sfsdfsd")
}

and open the project in RStudio, ".env" isn't created:

ls(envir=.env) returns Error in ls(envir = .env) : object '.env' not found

.env$test() returns Error: object '.env' not found

Running the same code in RStudio is working though:

ls(envir=.env) then returns [1] "test"

Creating an environment via .RProfile file is recommended a lot (eg this blog post).

Has RStudio changed its behaviour?

Peter W.
  • 21
  • 2
  • If I make this Rprofile and start Rstudio in that directory, .env is defined. Are you sure R is starting in the correct directory? – alan ocallaghan Dec 06 '19 at 13:03
  • Add `cat("Hello, world\n")` to your .Rprofile and then start a fresh R session to be sure that your .Rprofile is being run. – G. Grothendieck Dec 06 '19 at 13:59
  • Thanks for your comments. Yes everything else in my Rprofile.site is working, also an additional ```cat("Hello, world\```` – Peter W. Dec 09 '19 at 12:35
  • It's working for me inside a project's .Rprofile file. That's enough for me at the moment. – Peter W. Dec 11 '19 at 08:57

0 Answers0