rpackagespatstatr-ppp

How to save ppp (planer point pattern dataframe) or a hyperframe created from different ppp objects in spatsat


I have created a "ppp" objects in R spatstat package and inserted them into a hyper frame I would like to run test later but how do I save them such that I can access them from my computer every time I need 2. I have imported a text comma-delimited (txt), land cover file and converted them into "ppp" and "im" objects as required in the spatstat package. after conversion, I created a data frame from these two files

library(maptools)
library(spatstat)
point.pattern <- read.table("occ.txt", header=TRUE)
shape <- readshapespatial("polygon")

use shape file as a window by using the as.own function

ow <- as.owin(shape)

convert the txt file into a ppp object.

pattern.ppp <- as.ppp(point.pattern, ow, fatal=TR)

imported the raster file and convert into im object

raster <- raster("land cover.tif")
raster.im <- as.im(raster)

create a hyper frame hyper

frame <- hyperframe(X=pattern.ppp, Y=list(raster.im)

write and save the hyper frame data now

I completely do not know the function to use in order to save my hyper frame data such that I can access them any time from my computer minus rewriting the codes every time


Solution

  • You can save any R object using saveRDS():

    saveRDS(frame, "your_filename.rds")
    

    Later you can read it back in with readRDS():

    frame <- readRDS("your_filename.rds")