m trying to use this code in R, with package RgoogleMaps
R Version: 2.14.2
RgoogleMaps version: 1.1.9.15
I need to use these old versions, here's the code (works with newest versions)
PlotOnStaticMap(Map,lon=x,lat=y, FUN = points, pch=16, col=Colors)
but with these old versions, I find these error message:
List of 8
$ lat.center: num 45.6
$ lon.center: num 12.4
$ zoom : num 9
$ myTile : 'nativeRaster' int [1:640, 1:640] -1906967 -1906967 -1906967 -1446673 -1183245 -1183245 -1183245 -1183245 -1445905 -2235674 ...
..- attr(*, "channels")= int 4
$ BBOX :List of 2
..$ ll: num [1, 1:2] 45 11.5
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr "Y"
.. .. ..$ : chr [1:2] "lat" "lon"
..$ ur: num [1, 1:2] 46.2 13.3
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr "Y"
.. .. ..$ : chr [1:2] "lat" "lon"
$ url : chr "google"
$ size : int [1:2] 640 640
$ SCALE : num 1
NULL
[1] -148.7783 210.1525
[1] -131.7210 127.5206
Errore in plot.xy(xy.coords(x, y), type = type, ...) :
plot.new hasn't been called yet
What's the problem?
Error was in Map. It was downloaded with newest version of the package, and oldest version didn't recognized it
Related
In short: I have a spatialpixeldataframe of a utilization distribution of an animal across a grid (udspdf) which I need to convert to estUD-class.
Background to how I got there: After calculating the KDE of a single animal, I then need to convert the estUD-class object to a spatialpixeldataframe in order to remove non-habitat cells, and rescale the utilisation distribution of the habitat-cells to 1. I then need to convert the spatialpixeldataframe back to an estUD class file so that I can run kerneloverlaphr() on it.
I have the following code, which converts it to an estUDm-class. But I need it in estUD-class, as there is only one animal.
re <- lapply(1:ncol(udspdf), function(i) {
so <- new("estUD", udspdf[,i])
so#h <- list(h=0, meth="specified") # specify dummy h values: they are only required to recreate the estUDm
so#vol <- FALSE
return(so)
})
names(re) <- names(udspdf)
class(re) <- "estUDm"
image(re)
If I just change
class(re) <- "estUD"
This seems to work, but then I can see there is an issue because
image(re)
renders the following error: Error in is(x, "GridTopology") :
trying to get slot "grid" from an object (class "estUD") that is not an S4 object
I am sorry I do not know how to provide a reproducible example for such an example as the data is quite complex. I hope that a general code exists.
Any pointers appreciated!
> str(re)
List of 1
$ ud:Formal class 'estUD' [package "adehabitatHR"] with 9 slots
.. ..# h :List of 2
.. .. ..$ h : num 0
.. .. ..$ meth: chr "specified"
.. ..# vol : logi FALSE
.. ..# data :'data.frame': 4400000 obs. of 1 variable:
.. .. ..$ ud: num [1:4400000] 0 0 0 0 0 0 0 0 0 0 ...
.. ..# coords.nrs : num(0)
.. ..# grid :Formal class 'GridTopology' [package "sp"] with 3 slots
.. .. .. ..# cellcentre.offset: Named num [1:2] -70 -60
.. .. .. .. ..- attr(*, "names")= chr [1:2] "Var2" "Var1"
.. .. .. ..# cellsize : Named num [1:2] 0.01 0.01
.. .. .. .. ..- attr(*, "names")= chr [1:2] "Var2" "Var1"
.. .. .. ..# cells.dim : Named int [1:2] 2000 2200
.. .. .. .. ..- attr(*, "names")= chr [1:2] "Var2" "Var1"
.. ..# grid.index : int [1:4400000] 1 2 3 4 5 6 7 8 9 10 ...
.. ..# coords : num [1:4400000, 1:2] -70 -70 -70 -70 -70 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : NULL
.. .. .. ..$ : chr [1:2] "Var2" "Var1"
.. ..# bbox : num [1:2, 1:2] -70 -60 -50 -38
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:2] "Var2" "Var1"
.. .. .. ..$ : chr [1:2] "min" "max"
.. ..# proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. .. ..# projargs: chr "+proj=longlat +datum=WGS84 +no_defs"
- attr(*, "class")= chr "estUDm"
my code for kerneloverlaphr(), which works with the outputs stright from kernelUD() (estUD-class) is as follows:
NWI15b, BCI15b and BCI15i are my individual animals
library(adehabitatHR)
# convert list of KDEs (estUDs) to class estUDm
tot <- list(NWI15b=NWI15b, BCI15b=BCI15b, BCI15i=BCI15i)
class(tot) <- "estUDm"
#calculate overlap using kerneloverlaphr
kerneloverlaphr(tot, method = c("BA"), percent = 95, conditional = FALSE)
dput(head(as.data.frame.estUD(re), n = 10))
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'head': no method or default for coercing “estUDm” to “SpatialPixelsDataFrame”
> unique(re#data$ud)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'unique': trying to get slot "data" from an object (class "estUDm") that is not an S4 object
structure of object fed to kernelUD
str(track_sp)
Formal class 'SpatialPoints' [package "sp"] with 3 slots
..# coords : num [1:9790, 1:2] -59.2 -59.2 -59.2 -59.2 -59.2 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:9790] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:2] "x" "y"
..# bbox : num [1:2, 1:2] -65.8 -55.6 -56.1 -52.2
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "x" "y"
.. .. ..$ : chr [1:2] "min" "max"
..# proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..# projargs: chr "+proj=longlat +datum=WGS84 +no_defs"
Where we have
re <- lapply(1:ncol(udspdf), function(i) {
so <- new("estUD", udspdf[,i])
so#h <- list(h=0, meth="specified") # specify dummy h values: they are only required to recreate the estUDm
so#vol <- FALSE
return(so)
})
> names(re) <- names(udspdf)
> class(re) <- "estUDm"
> image(re)
We then need to simply add this:
colonyA <- re[[1]]
#and then do the same after running the code for the next colony
colonyB<- re[[1]]
I am trying to read in a geojson file (https://www.svz-bw.de/fileadmin/verkehrszentrale/RadNETZ-BW_Daten_GeoJSON_2018-20.zip) in R.
I have tried different packages but my knowledge is too limited to find the errors and solve them. Im new to spatial data in R, especially reading geojson file format.
Googling and searching in stackoverflow hasnt helped.
geojsonR::FROM_geojson("../Sonstiges/RadNETZ.geojson")
Error in unlink(x) : file name conversion problem -- name too long?
geojsonR::FROM_GeoJson("../Sonstiges/RadNETZ.geojson")
Error in export_From_geojson(url_file_string, Flatten_Coords,
Average_Coordinates, : invalid GeoJson geometry object -->
geom_OBJ() function
Your file does not comply with the current GeoJSON standards; it uses a projected coordinate reference system, which goes against RFC 7946 - https://www.rfc-editor.org/rfc/rfc7946#page-12
This may, and may not, be the reason why geojson specific packages have hard time interpreting it.
In order to process your file I suggest using {sf}, which is - via GDAL and PROJ - able to digest the file.
library(dplyr)
library(sf)
asdf <- st_read("RadNETZ.geojson") %>%
st_transform(4326) # safety of unprojected CRS
plot(st_geometry(asdf))
As #Jindra Lacko mentioned your 'RadNETZ.geojson' file does not comply with the RFC 7946 that's why you receive the error. If you don't have GDAL installed on your Operating System besides the 'sf' package you can use either the geojsonR::shiny_from_JSON (which does not follow the RFC and is meant to be used in shiny applications),
dat = geojsonR::shiny_from_JSON("../Sonstiges/RadNETZ.geojson")
str(dat)
List of 4
$ crs :List of 2
..$ properties:List of 1
.. ..$ name: chr "urn:ogc:def:crs:EPSG::31467"
..$ type : chr "name"
$ features:List of 70097
..$ :List of 3
.. ..$ geometry :List of 2
.. .. ..$ coordinates:List of 6
.. .. .. ..$ :List of 2
.. .. .. .. ..$ : num 3563993
.. .. .. .. ..$ : num 5353055
.. .. .. ..$ :List of 2
.. .. .. .. ..$ : num 3564002
.. .. .. .. ..$ : num 5353070
.. .. .. ..$ :List of 2
.. .. .. .. ..$ : num 3564009
.. .. .. .. ..$ : num 5353087
.. .. .. ..$ :List of 2
.. .. .. .. ..$ : num 3564013
.. .. .. .. ..$ : num 5353103
.. .. .. ..$ :List of 2
.. .. .. .. ..$ : num 3564016
.. .. .. .. ..$ : num 5353109
.. .. .. ..$ :List of 2
.. .. .. .. ..$ : num 3564030
.. .. .. .. ..$ : num 5353121
.. .. ..$ type : chr "LineString"
.. ..$ properties:List of 24
.....
or the jsonlite::fromJSON function,
dat = jsonlite::fromJSON("../Sonstiges/RadNETZ.geojson")
str(dat)
List of 4
$ type : chr "FeatureCollection"
$ name : chr "sql_statement"
$ crs :List of 2
..$ type : chr "name"
..$ properties:List of 1
.. ..$ name: chr "urn:ogc:def:crs:EPSG::31467"
$ features:'data.frame': 70097 obs. of 3 variables:
..$ type : chr [1:70097] "Feature" "Feature" "Feature" "Feature" ...
..$ properties:'data.frame': 70097 obs. of 24 variables:
.. ..$ gid : int [1:70097] 4 15 23 22 45 72 60 74 13072 75 ...
.. ..$ lrvn_kat: int [1:70097] 3 1 1 3 1 1 3 1 3 1 ...
.....
For the record I'm the author / maintainer of the geojsonR package
I have tried to figure out actual memory requirements for storing particular object. I tried two methods:
object.size(obj)
save(obj, file = "obj.Rdata") and checking the file size.
The .Rdata file is compressed so it was always smaller than what object.size() has returned, until I saw this object:
> object.size(out)
144792 bytes
> save(out, file = "out.Rdata")
# the file has 211 759 bytes
When I open the file in new R and run object.size(out), it reports 144792 bytes again.
Any idea how this can happen?
I don't want to post the complete object here since it contains closed data, but I can post the str output at least (it is the output of the R2jags::jags call - object of class rjags):
> str(out)
List of 6
$ model :List of 8
..$ ptr :function ()
..$ data :function ()
..$ model :function ()
..$ state :function (internal = FALSE)
..$ nchain :function ()
..$ iter :function ()
..$ sync :function ()
..$ recompile:function ()
..- attr(*, "class")= chr "jags"
$ BUGSoutput :List of 24
..$ n.chains : int 2
..$ n.iter : num 1000
..$ n.burnin : num 500
..$ n.thin : num 1
..$ n.keep : int 500
..$ n.sims : int 1000
..$ sims.array : num [1:500, 1:2, 1:5] -5.86e-06 -3.78e-02 6.92e-02 4.33e-02 4.34e-02 ...
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : NULL
.. .. ..$ : NULL
.. .. ..$ : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
..$ sims.list :List of 5
.. ..$ alpha : num [1:1000, 1] 0.04702 -0.00818 0.03757 0.00799 0.00369 ...
.. ..$ beta : num [1:1000, 1] -0.135 -0.2082 -0.0112 -0.129 -0.1613 ...
.. ..$ deviance : num [1:1000, 1] 16028 22052 16127 16057 16141 ...
.. ..$ overdisp_sigma: num [1:1000, 1] 0.26506 0.00821 0.24998 0.25793 0.26013 ...
.. ..$ yr_reff_sigma : num [1:1000, 1] 0.1581 0.176 0.0695 0.1052 0.1043 ...
..$ sims.matrix : num [1:1000, 1:5] 0.04702 -0.00818 0.03757 0.00799 0.00369 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
..$ summary : num [1:5, 1:9] 3.16e-03 -1.20e-01 1.68e+04 2.29e-01 1.19e-01 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
.. .. ..$ : chr [1:9] "mean" "sd" "2.5%" "25%" ...
..$ mean :List of 5
.. ..$ alpha : num [1(1d)] 0.00316
.. ..$ beta : num [1(1d)] -0.12
.. ..$ deviance : num [1(1d)] 16835
.. ..$ overdisp_sigma: num [1(1d)] 0.229
.. ..$ yr_reff_sigma : num [1(1d)] 0.119
..$ sd :List of 5
.. ..$ alpha : num [1(1d)] 0.0403
.. ..$ beta : num [1(1d)] 0.0799
.. ..$ deviance : num [1(1d)] 2378
.. ..$ overdisp_sigma: num [1(1d)] 0.0702
.. ..$ yr_reff_sigma : num [1(1d)] 0.036
..$ median :List of 5
.. ..$ alpha : num [1(1d)] 0.00399
.. ..$ beta : num [1(1d)] -0.123
.. ..$ deviance : num [1(1d)] 16209
.. ..$ overdisp_sigma: num [1(1d)] 0.252
.. ..$ yr_reff_sigma : num [1(1d)] 0.111
..$ root.short : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
..$ long.short :List of 5
.. ..$ : int 1
.. ..$ : int 2
.. ..$ : int 3
.. ..$ : int 4
.. ..$ : int 5
..$ dimension.short: num [1:5] 0 0 0 0 0
..$ indexes.short :List of 5
.. ..$ : NULL
.. ..$ : NULL
.. ..$ : NULL
.. ..$ : NULL
.. ..$ : NULL
..$ last.values :List of 2
.. ..$ :List of 4
.. .. ..$ alpha : num [1(1d)] 0.0296
.. .. ..$ beta : num [1(1d)] -0.0964
.. .. ..$ deviance : num [1(1d)] 16113
.. .. ..$ overdisp_sigma: num [1(1d)] 0.265
.. ..$ :List of 4
.. .. ..$ alpha : num [1(1d)] 0.0334
.. .. ..$ beta : num [1(1d)] -0.228
.. .. ..$ deviance : num [1(1d)] 16139
.. .. ..$ overdisp_sigma: num [1(1d)] 0.257
..$ program : chr "jags"
..$ model.file : chr "model.txt"
..$ isDIC : logi TRUE
..$ DICbyR : logi TRUE
..$ pD : num 2830902
..$ DIC : num 2847738
..- attr(*, "class")= chr "bugs"
$ parameters.to.save: chr [1:5] "alpha" "beta" "overdisp_sigma" "yr_reff_sigma" ...
$ model.file : chr "model.txt"
$ n.iter : num 1000
$ DIC : logi TRUE
- attr(*, "class")= chr "rjags"
One way this can happen is if the object has an associated environment that needs saving with it if it is to make sense. This comes up most commonly in the context of "closures" (see here for one explanation).
Without a reproducible example (and without having used R2jags myself) I can't tell you whether that's what is going on in your case, but it at least seems plausible, given that: (a) closures seem to be the most common cause of this situation; (b) based on the output of str(out), your object seems to include a bunch of functions; and (c) it seems like this might be a useful way to organize a computation-heavy and possibly parallelizable procedure like MCMC.
## Define a function "f" that returns a closure, here assigned to the object "y"
f <- function() {
x <- 1:1e6
function() 2*x
}
y <- f()
environment(y)
# <environment: 0x0000000008409ab8>
object.size(y)
# 1216 bytes
save(y, file="out.Rdata")
file.info("out.Rdata")$size
# [1] 2128554
I have been following an online example for R Kohonen self-organising maps (SOM) which suggested that the data should be centred and scaled before computing the SOM.
However, I've noticed the object created seems to have attributes for centre and scale, in which case am I really applying a redundant step by centring and scaling first? Example script below
# Load package
require(kohonen)
# Set data
data(iris)
# Scale and centre
dt <- scale(iris[, 1:4],center=TRUE)
# Prepare SOM
set.seed(590507)
som1 <- som(dt,
somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
str(som1)
The output from the last line of the script is:
List of 13
$ data :List of 1
..$ : num [1:150, 1:4] -0.898 -1.139 -1.381 -1.501 -1.018 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:4] "Sepal.Length" "Sepal.Width" "Petal.Length"
"Petal.Width"
.. ..- attr(*, "scaled:center")= Named num [1:4] 5.84 3.06 3.76 1.2
.. .. ..- attr(*, "names")= chr [1:4] "Sepal.Length" "Sepal.Width"
"Petal.Length" "Petal.Width"
.. ..- attr(*, "scaled:scale")= Named num [1:4] 0.828 0.436 1.765 0.762
.. .. ..- attr(*, "names")= chr [1:4] "Sepal.Length" "Sepal.Width"
"Petal.Length" "Petal.Width"
$ unit.classif : num [1:150] 3 5 5 5 4 2 4 4 6 5 ...
$ distances : num [1:150] 0.0426 0.0663 0.0768 0.0744 0.1346 ...
$ grid :List of 6
..$ pts : num [1:36, 1:2] 1.5 2.5 3.5 4.5 5.5 6.5 1 2 3 4 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "x" "y"
..$ xdim : num 6
..$ ydim : num 6
..$ topo : chr "hexagonal"
..$ neighbourhood.fct: Factor w/ 2 levels "bubble","gaussian": 1
..$ toroidal : logi FALSE
..- attr(*, "class")= chr "somgrid"
$ codes :List of 1
..$ : num [1:36, 1:4] -0.376 -0.683 -0.734 -1.158 -1.231 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:36] "V1" "V2" "V3" "V4" ...
.. .. ..$ : chr [1:4] "Sepal.Length" "Sepal.Width" "Petal.Length"
"Petal.Width"
$ changes : num [1:500, 1] 0.0445 0.0413 0.0347 0.0373 0.0337 ...
$ alpha : num [1:2] 0.05 0.01
$ radius : Named num [1:2] 3.61 0
..- attr(*, "names")= chr [1:2] "66.66667%" ""
$ user.weights : num 1
$ distance.weights: num 1
$ whatmap : int 1
$ maxNA.fraction : int 0
$ dist.fcts : chr "sumofsquares"
- attr(*, "class")= chr "kohonen"
Note notice that in lines 7 and 10 of the output there are references to centre and scale. I would appreciate an explanation as to the process here.
Your step with scaling is not redundant because in source code there are no scaling, and attributes, that you see in 7 and 10 are attributes from train dataset.
To check this, just run and compare results of this chunk of code:
# Load package
require(kohonen)
# Set data
data(iris)
# Scale and centre
dt <- scale(iris[, 1:4],center=TRUE)
#compare train datasets
str(dt)
str(as.matrix(iris[, 1:4]))
# Prepare SOM
set.seed(590507)
som1 <- kohonen::som(dt,
kohonen::somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
#without scaling
som2 <- kohonen::som(as.matrix(iris[, 1:4]),
kohonen::somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
#compare results of som function
str(som1)
str(som2)
I have tried to figure out actual memory requirements for storing particular object. I tried two methods:
object.size(obj)
save(obj, file = "obj.Rdata") and checking the file size.
The .Rdata file is compressed so it was always smaller than what object.size() has returned, until I saw this object:
> object.size(out)
144792 bytes
> save(out, file = "out.Rdata")
# the file has 211 759 bytes
When I open the file in new R and run object.size(out), it reports 144792 bytes again.
Any idea how this can happen?
I don't want to post the complete object here since it contains closed data, but I can post the str output at least (it is the output of the R2jags::jags call - object of class rjags):
> str(out)
List of 6
$ model :List of 8
..$ ptr :function ()
..$ data :function ()
..$ model :function ()
..$ state :function (internal = FALSE)
..$ nchain :function ()
..$ iter :function ()
..$ sync :function ()
..$ recompile:function ()
..- attr(*, "class")= chr "jags"
$ BUGSoutput :List of 24
..$ n.chains : int 2
..$ n.iter : num 1000
..$ n.burnin : num 500
..$ n.thin : num 1
..$ n.keep : int 500
..$ n.sims : int 1000
..$ sims.array : num [1:500, 1:2, 1:5] -5.86e-06 -3.78e-02 6.92e-02 4.33e-02 4.34e-02 ...
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : NULL
.. .. ..$ : NULL
.. .. ..$ : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
..$ sims.list :List of 5
.. ..$ alpha : num [1:1000, 1] 0.04702 -0.00818 0.03757 0.00799 0.00369 ...
.. ..$ beta : num [1:1000, 1] -0.135 -0.2082 -0.0112 -0.129 -0.1613 ...
.. ..$ deviance : num [1:1000, 1] 16028 22052 16127 16057 16141 ...
.. ..$ overdisp_sigma: num [1:1000, 1] 0.26506 0.00821 0.24998 0.25793 0.26013 ...
.. ..$ yr_reff_sigma : num [1:1000, 1] 0.1581 0.176 0.0695 0.1052 0.1043 ...
..$ sims.matrix : num [1:1000, 1:5] 0.04702 -0.00818 0.03757 0.00799 0.00369 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
..$ summary : num [1:5, 1:9] 3.16e-03 -1.20e-01 1.68e+04 2.29e-01 1.19e-01 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
.. .. ..$ : chr [1:9] "mean" "sd" "2.5%" "25%" ...
..$ mean :List of 5
.. ..$ alpha : num [1(1d)] 0.00316
.. ..$ beta : num [1(1d)] -0.12
.. ..$ deviance : num [1(1d)] 16835
.. ..$ overdisp_sigma: num [1(1d)] 0.229
.. ..$ yr_reff_sigma : num [1(1d)] 0.119
..$ sd :List of 5
.. ..$ alpha : num [1(1d)] 0.0403
.. ..$ beta : num [1(1d)] 0.0799
.. ..$ deviance : num [1(1d)] 2378
.. ..$ overdisp_sigma: num [1(1d)] 0.0702
.. ..$ yr_reff_sigma : num [1(1d)] 0.036
..$ median :List of 5
.. ..$ alpha : num [1(1d)] 0.00399
.. ..$ beta : num [1(1d)] -0.123
.. ..$ deviance : num [1(1d)] 16209
.. ..$ overdisp_sigma: num [1(1d)] 0.252
.. ..$ yr_reff_sigma : num [1(1d)] 0.111
..$ root.short : chr [1:5] "alpha" "beta" "deviance" "overdisp_sigma" ...
..$ long.short :List of 5
.. ..$ : int 1
.. ..$ : int 2
.. ..$ : int 3
.. ..$ : int 4
.. ..$ : int 5
..$ dimension.short: num [1:5] 0 0 0 0 0
..$ indexes.short :List of 5
.. ..$ : NULL
.. ..$ : NULL
.. ..$ : NULL
.. ..$ : NULL
.. ..$ : NULL
..$ last.values :List of 2
.. ..$ :List of 4
.. .. ..$ alpha : num [1(1d)] 0.0296
.. .. ..$ beta : num [1(1d)] -0.0964
.. .. ..$ deviance : num [1(1d)] 16113
.. .. ..$ overdisp_sigma: num [1(1d)] 0.265
.. ..$ :List of 4
.. .. ..$ alpha : num [1(1d)] 0.0334
.. .. ..$ beta : num [1(1d)] -0.228
.. .. ..$ deviance : num [1(1d)] 16139
.. .. ..$ overdisp_sigma: num [1(1d)] 0.257
..$ program : chr "jags"
..$ model.file : chr "model.txt"
..$ isDIC : logi TRUE
..$ DICbyR : logi TRUE
..$ pD : num 2830902
..$ DIC : num 2847738
..- attr(*, "class")= chr "bugs"
$ parameters.to.save: chr [1:5] "alpha" "beta" "overdisp_sigma" "yr_reff_sigma" ...
$ model.file : chr "model.txt"
$ n.iter : num 1000
$ DIC : logi TRUE
- attr(*, "class")= chr "rjags"
One way this can happen is if the object has an associated environment that needs saving with it if it is to make sense. This comes up most commonly in the context of "closures" (see here for one explanation).
Without a reproducible example (and without having used R2jags myself) I can't tell you whether that's what is going on in your case, but it at least seems plausible, given that: (a) closures seem to be the most common cause of this situation; (b) based on the output of str(out), your object seems to include a bunch of functions; and (c) it seems like this might be a useful way to organize a computation-heavy and possibly parallelizable procedure like MCMC.
## Define a function "f" that returns a closure, here assigned to the object "y"
f <- function() {
x <- 1:1e6
function() 2*x
}
y <- f()
environment(y)
# <environment: 0x0000000008409ab8>
object.size(y)
# 1216 bytes
save(y, file="out.Rdata")
file.info("out.Rdata")$size
# [1] 2128554