Skip to content

Saving a variogram in gstat

9 messages · carolina monmany, Mauricio Zambrano-Bigiarini, Sarah Goslee

#
The following reproducible example works for me
(please run it in a new session):

  -------- START ----------
  library(gstat)
  data(meuse)

  # no trend:
  coordinates(meuse) = ~x+y
  myvgm <- variogram(log(zinc)~1, meuse)

  # saving the variogram to your home directory
  setwd("~")
  save(myvgm, file="Myvgm.RData")

  ## remove (almost) everything in the working environment.
  ## IMPORTANT:: You will get no warning, so
  ## don't do this unless you are really sure.
  rm(list = ls())

  ## Loading the variogram
  load("Myvgm.RData")
  summary(myvgm)
-------- END ----------


IHTH,

Mauricio
#
On Mon, Nov 5, 2012 at 10:26 AM, carolina monmany <acmonmany at gmail.com> wrote:
Of course it is:

"tuc11.2.200.var.Rdata" is a character string, as is anything in quotes.
That's not anything, just the name of your Rdata file. The R object
itself keeps the same name as it had when you saved it: variog11.2
summary(variog11.2)
will show you its properties. If you ls() you'll see there is no R object called
tuc11.2.200.var

If you want your saved object to have that name, you need to rename it
before saving.

Sarah


--
Sarah Goslee
http://www.functionaldiversity.org
#
Hi Carolina,

You can save all the variables of your current session by using 'save.image':

save.image("myVGMsession.RData")

and then load it as before (from Windows or GNU/Linux):

load("myVGMsession.RData")

Kinds,

Mauricio

2012/11/5 carolina monmany <acmonmany at gmail.com>:

  
    
#
On Mon, Nov 5, 2012 at 10:55 AM, carolina monmany <acmonmany at gmail.com> wrote:
The R object named variog11.2 is saved in the binary file named
tuc11.2.200.var.Rdata. That file can be copied to other computers and
loaded using load(), which will create the variogram variog11.2 in
that workspace (potentially overwriting any object already named
variog11.2).

I don't understand your question about directories.

Sarah
--
Sarah Goslee
http://www.functionaldiversity.org