I am trying to convert a SpatialPolygonsDataFrame layer to a DataFrame to create plots using
ggplot2 in an R Script within QGIS. I've used spatial join to append averages of BioClim mean temperature tiles within each of many polygon land class features.
When I pull up the attribute table for the layer, all values are filled for each of the features; however, R in QGIS keeps throwing the error:
Error in data.frame(x=Layer[[X]], y=Layer[[Y]]): arguments imply differing number of rows: 9382, 0 Execution halted
For some reason it doesn't seem to be picking up the second field of the SpatialPolygonsDataFrame object.
The R script I've composed thus far is here:
##Vector Processing=group ##showplots ##Layer=vector ##X=Field Layer ##Y=Field Layer library("ggplot2") ggplot(data=data.frame(x=Layer[[X]], y=Layer[[Y]])) + geom_histogram(aes(x=x)) + facet_wrap(~y)
This question is a follow-up to one of my earlier ones, which is here: Use facet wrap in ggplot2 with QGIS?
Does anyone have an ideas of why this error is being thrown?