1

I have a script in .First(). I saved it to .RData and put it in a folder to which I point in a Windows shortcut of Rterm.exe 64-bit (like described here). When I open the shortcut I get the error "could not find function..", even for base functions..

like so:

.First <- function() {
plot(rnorm(100))
}

> sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Austria.1252  LC_CTYPE=German_Austria.1252   
[3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Austria.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_2.15.0
Community
  • 1
  • 1
Kay
  • 2,702
  • 6
  • 32
  • 48

1 Answers1

1

Files with .RData extenstions are often assigned as data rather than source files. The problem however is that the .First scripts can only use functions in the base package unlees the other packages are first loaded.

.First <- function() { require(graphics)
plot(rnorm(100))
}

?Startup

Personally, I would name this with a .R extension.

IRTFM
  • 258,963
  • 21
  • 364
  • 487