# Problem with aes and ggplot2 while plotting gwr/aes length

Having trouble with the following code while doing a Geo-regression

modelo1 <- lm(MF\$MFALC_15_2 ~ MF\$MFEFF2015+MF\$agro1315+MF\$MEDALC+MF\$density)
summary(modelo1)
plot(modelo1, which=3)
residuo <- residuals(modelo1)
cores <- c("green","darkgreen","blue","darkblue")
map.residuos <- SpatialPointsDataFrame(data=data.frame(residuo),
coords=cbind(MF\$COORD_X,MF\$COORD_Y))
spplot(map.residuos, cuts=quantile(residuo), col.regions=cores, cex=1)
GWRBandwith <- gwr.sel(MF\$MFALC_15_2 ~
MF\$MFEFF2015+MF\$agro1315+MF\$MEDALC+MF\$density, data=MF,
gwr.model = gwr(MF\$MFALC_15_2 ~
MF\$MFEFF2015+MF\$agro1315+MF\$MEDALC+MF\$density, data=MF,
coords=cbind(MF\$COORD_X,MF\$COORD_Y), adapt = GWRBandwith, hatmatrix = TRUE,
se.fit = TRUE)
gwr.model
workdir <- "C:\\Users\\pedro\\Documents\\Time Series\\Luciano"

fill=id))+geom_polygon()+guides(fill=FALSE)

#this is where things start to go wrong
aes(x=x,y=y))+geom_point(aes(colour=MF\$coefMFEFF2015))+
mid="white",high="blue",midpoint=0,space="rgb",
na.value="grey50",guide="colourbar",guide_legend(title="coefs"))
colour="grey")+coord_equal()

It returns the error "Aesthetics must be either length 1 or the same as the data (399): colour, x, y" The fortify function breaks the polygons of my shapefile into millions of rows, but it works for plotting the map by itself. When I try to plot the regression (MF\$coefs...) within the shape the lenght of the regression (399) is not compatible with the lenght of rows in the shapefile dataframe. I've tried changing the arguments for aes (tried x=long, group=group, group=id,y=lat etc...)

• Welcome to GIS SE, please ckeck the tour and edit your question. Also, upload some data or make a reproducible example to know where the issue is – aldo_tapia Apr 20 '18 at 12:16
• Done, uploaded data on gdrive – Pedro Iora Apr 20 '18 at 13:04
• You upload only .shp file. Do you know how to share shapefiles? – aldo_tapia Apr 20 '18 at 14:41
• Sorry, my mistake, reuploading the .rar file with all the correct extensions. Having some troubles because of doing so through the cellphone – Pedro Iora Apr 20 '18 at 14:49