0

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

markalex
  • 8,623
  • 2
  • 7
  • 32
Richard M
  • 5
  • 3
  • Can you clarify exactly what you want to do? Do you want to be able to use your hyperframe next time you start R, without having to rerun the code again? Or do you want to be able to use the hyperframe in some other program? – A. S. K. Aug 09 '19 at 18:19
  • Yes exactly that – Richard M Aug 09 '19 at 18:52
  • Exactly which? (1) Use the hyperframe next time you start R. (2) Use the hyperframe in some other program. (1), (2), or both? – A. S. K. Aug 09 '19 at 19:00

1 Answers1

0

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")
Ege Rubak
  • 4,347
  • 1
  • 10
  • 18