I'm trying to use R scripts within QGIS thanks to Processing. There are some example scripts available and I achieved to plots different columns of the attribute table (with the plot built-in package).
What I cannot do is using the ggplot package. This is one of the simple code I've written:
##Vector processing=group
##showplots
##Layer=vector
##Field1=Field Layer
##Field2=Field Layer
library("ggplot2")
ggplot(Layer)+
geom_point(aes([[Field1]], [[Field2]]))
But none plot is shown.
Log output says:
R execution commands
options("repos"="http://cran.at.r-project.org/")
tryCatch(find.package("ggplot2"), error=function(e) install.packages("ggplot2", dependencies=TRUE))
tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE))
tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE))
library("raster")
library("rgdal")
Layer = readOGR("/media/data/Universita/brema/gis/file_tesi/piezo_e_logger",layer="piezo_tutto_finale")
Field1="Br"
Field2="Ca"
png("/tmp/processing/f02d43598eb44b63aec89c02de38af54/RPLOTS.html.png")
library("ggplot2")
ggplot(Layer) + geom_point(aes(Layer[[Field1]], Layer[[Field2]]))
dev.off()
And that's a piece of the dbf table (trying to plot Cl vs Br):
ID Cl Br
2818/22/0834 125.70 0.20
2818/22/0851 219.12 0.29
2818/22/0853 298.55 0.26
2818/22/0886 132.32 0.09
B0F 520.60 1.01
B12T 3435.49 3.83
B1T 2322.61 2.54
B21T 2800.90 3.18
B22F 366.87 0.64
B26T 1891.63 2.10
B33F 216.97 0.62
B4F 383.98 0.44
P1 82.01 0.14
P21 365.56 0.74
P24 199.98 0.73
P25 308.71 0.90
P27 217.58 0.58
P28 436.09 0.32
P29 711.77 1.08