[R-sig-Geo] Saving a variogram in gstat

Sarah Goslee sarah.goslee at gmail.com
Mon Nov 5 16:42:24 CET 2012


On Mon, Nov 5, 2012 at 10:26 AM, carolina monmany <acmonmany at gmail.com> wrote:
> Thanks Sarah and Mauricio,
>
> here's the example
>
>> library(gstat)
>> setwd("/home/acmonmany/matricesDN")
>> tuc11.2.frm = read.table("plot11_2.txt", header=T)
>> coordinates(tuc11.2.frm) <- c("X", "Y")
>> proj4string(tuc11.2.frm) <-CRS("+proj=utm +zone=20 +south +ellps=intl
> +towgs84=-355,21,72,0,0,0,0 +units=m +no_defs")
>> variog11.2 <- variogram(reflectance~1, data=tuc11.2.frm)
>> save(variog11.2, file="tuc11.2.200.var.Rdata")
>
> NOW when I try to load the saved file (I do not change directory and I can
> see the files there, in the directory stated above):
>
>
>> load("tuc11.2.200.var.Rdata")
>> class("tuc11.2.200.var.Rdata")
> [1] "character"

Of course it is:

"tuc11.2.200.var.Rdata" is a character string, as is anything in quotes.


>> summary(tuc11.2.200.var)
> Error in summary(tuc11.2.200.var) :
>   error in evaluating the argument 'object' in selecting a method for
> function 'summary': Error: object 'tuc11.2.200.var' not found

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



More information about the R-sig-Geo mailing list