简体   繁体   中英

Obtain resulting table to plot graphics in R

I'm new with R in QGIS, I could write a simple script, and I want to obtain the table resulting, the table which R uses to create the plot graphics.

How can I do that?

This is the script:

##Point pattern analysis=group
##Layer=vector
##Titulo=string
##showplots
library("maptools")
library("spatstat")    
K <- Kest(as.ppp(Layer))
plot(K, main=Titulo)

Can anyone help me?

The QGIS processing module runs each R script in a separate R session. If you want to save anything created then you need to save it to a file in your script, for example:

 save(K,file="K.RData")

Then in another R session you can do:

 load("K.RData")
 library(spatstat)

and now K is restored.

You might want to pass the save file name as another parameter to your processing script, or you may want to not do this further work in QGIS...

If you want to save this as a DBF file then there's a problem caused by the fact that K is a special kind of data frame - use write.dbf(as.data.frame(K),"/path/to/K.dbf") to convert it to a plain data frame for writing. This will lose some of the information such as labels and names of the various components but you can't store irregular data in a DBF.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM