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

Sarah Goslee sarah.goslee at gmail.com
Mon Nov 5 17:17:08 CET 2012


On Mon, Nov 5, 2012 at 10:55 AM, carolina monmany <acmonmany at gmail.com> wrote:
> I see, Sarah. Thank you!
>
> Now I need to transfer those variograms to my PC running windows and that
> was the reason I  was doing
>
> save(variog11.2, file="tuc11.2.200.var.Rdata")
>
> and transfering those files from Linux to Windows. Should I transfer the
> .Rdata in the directory instead? Where are the objects themselves?

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


>
> 2012/11/5 Sarah Goslee <sarah.goslee at gmail.com>
>
>> 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