문제

i am completely new in R. I am trying to save a spatialdataframe and a normal data frame within the same object. when I am applying the code below, it saves the object as a R workspace, is it normal? i mean I wnated to obtain a .rda data instead. What i specifically want to do is to obtain an R data with those two objects. I want the spatialdataframe to keep its spatial charactheristics. Can someone help me?

##import a text table 
mcvfinal<-read.csv("dataCPWithAge.csv",header=TRUE,sep=",",dec=".") 

##reading the shapefile 
library(rgdal) polypc1 <- readOGR(".", "CP3poly_Matchingshp")   

##saving the two frames into the same object 
save(mcvfinal,polypc1,file="polypc.Rdata")
도움이 되었습니까?

해결책

Try:

saveRDS(list(mcvfinal,polypc1),file="polypc.rds")

Load:

foo = readRDS("polypc.rds")

# mcvfinal is foo[[1]]
# polypc1 is foo[[2]]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top