using ggplot funtion

hi everyone, i m trying to run this function after importing shapefiles : gwr.point1<-ggplot(LondonWards, aes(x=x,y=y))+geom_point(aes(colour=LondonWards$coefjobindex))+scale_colour_gradient2(low ="red", mid = "white", high = "blue", midpoint = 0, space = "rgb", na.value = "grey50", guide = "colourbar", guide_legend(title="Coefs"))gwr.point1+geom_path(data=boroughoutline,aes(long, lat, group=id), colour="grey")+coord_equal()
the message that i recive is: Erreur : unexpected symbol in "plot(LondonWards, aes(x=x,y=y))+geom_point(aes(colour=LondonWards$coefjobindex))+scale_colour_gradient2(low ="red", mid = "white", high = "blue", midpoint = 0, space = "rgb", na.value = "grey5".
What can i do to fix this problem?
thank you for your help

I invented some data for your ggplot code and it seems to work fine. Does the following work for you?

library(ggplot2)
LondonWards <- data.frame(x = 1:20, y = 1:20, coefjobindex = sample(1:20))
gwr.point1 <- ggplot(LondonWards, aes(x=x,y=y))+
  geom_point(aes(colour=LondonWards$coefjobindex))+
  scale_colour_gradient2(low ="red", mid = "white", high = "blue", 
                         midpoint = 0, space = "rgb", na.value = "grey50", 
                         guide = "colourbar", guide_legend(title="Coefs"))
#> Warning: Non Lab interpolation is deprecated
boroughoutline <- data.frame(long = c(2,7,7,2, 2, 11,17,17,11,11),
                             lat = c(2,2, 12,12,2, 15, 15, 18, 18,15),
                             id = c(1,1,1,1,1,2,2,2,2,2))

gwr.point1+geom_path(data=boroughoutline,aes(long, lat, group=id), colour="grey")+
  coord_equal()

Created on 2020-01-02 by the reprex package (v0.3.0)

dear FJCC,
I try all the commands but long = c(2,7,7,2, 2, 11,17,17,11,11) mean the rows or clums or what exactly ?
thank you

That line is just part of defining the boroughoutline data frame. Execute all of

boroughoutline <- data.frame(long = c(2,7,7,2, 2, 11,17,17,11,11),
                             lat = c(2,2, 12,12,2, 15, 15, 18, 18,15),
                             id = c(1,1,1,1,1,2,2,2,2,2))

at one time and you will get a data frame that defines the rectangles drawn by geom_path in the subsequent ggplot command.

but i have 268 coordinates, what can i do ?

The code I posted was just a very simple example showing that your ggplot call works with the data I invented. If my example also works for you, then the problem is probably in your data. You have not shown anything about your data, so I cannot say anything about that at the moment.

i want to give data files but i don't know how i import here

The best approach is to make a Reproducible Example. I will post a link to a tutorial but you can also search for that term or for the abbreviation Reprex and find a lot of advice. The key is to make a data set that is not larger than needed to show the problem.

The error message ends in
na.value="grey5"
but in your code you have
na.value="grey50"
Are you sure the zero in "grey50" is actually a zero and not some other funky character?

thanks a lot everyone, i solved my problem

If your question's been answered (even if by you), would you mind choosing a solution? (See FAQ below for how).

Having questions checked as resolved makes it a bit easier to navigate the site visually and see which threads still need help.

Thanks

it is easy, you juste run the command for the shapefiles that contain polygons like following:
boroughs <- readOGR("C:/Users/asus/Desktop/R/TUN_adm2.shp")
and the other commands will give you the right results.
Amani

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.