I've been trying to get this working without any luck (I'm new to R so don't really know how to do much and have been following examples). Basically I have an R script created that will automatically load a map when run, saved as .R file:
library(maps)
library(maptools)
library(mapdata)
map('worldHires',
c('UK', 'Ireland', 'Isle of Man','Isle of Wight'),
xlim=c(-11,3), ylim=c(49,60.9))
I want this to happen automatically when I open the RGui
without having to go to load script, and then select run all. I've read about editing the Rprofile.site file
which I've done and I've added an entry to it:
.First <- function(){
library(maps)
library(maptools)
library(mapdata)
map('worldHires',
c('UK', 'Ireland', 'Isle of Man','Isle of Wight'),
xlim=c(-11,3), ylim=c(49,60.9))
}
However, when I start R, I think it loads the libraries but then it says:
Error in maptype(database) : could not find function "data"
and no map is produced. However it works perfectly fine when I load the script manually and then press run all.
Am I doing something wrong here? Does the .First
function only load packages? What would make it work? I've also tried just using source(script location)
in the first function and that gives the same error.