[Qgis-user] QGIS-R

Daniel Torres nobeeakon at gmail.com
Wed Jun 10 21:12:26 PDT 2015


Hi every one, I'm having a hard time with Sextante and R. I'm trying to
make a little script to calculate the sum of a variable per cathegory, the
script runs in R, but I can't understand how to make it work in QGIS...

I haven't found many examples on QGIS-R, and the few ones use only one
variable...

Any help is welcome (any documentation or examples are very welcome),
Thanks,
Daniel




##Basic statistics=group
##Layer=vector
##valores=Field Layer
##categorias=Field Layer
valores<-Layer[[valores]]
categorias<-Layer[[categorias]]
catego<-as.factor(categorias)
catego_unicos<-unique(catego)
suma<-NA;suma<-data.frame(suma)
for(i in 1:length(catego_unicos)){
suma[i,1]<-sum(valores[catego==catego_unicos[i]])
}
colnames(suma)<-"suma"
rownames(suma)<-catego_unicos
>suma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150610/1dcaf6a9/attachment.html>


More information about the Qgis-user mailing list