1

I am a beginner in R. I have searched extensively for a solution to my problem, but have come up short.

I am graphing samples from three different populations (A,B or C) in a scatterplot. The point on the graph is determined by the samples longitude (x-axis) and latitude (y-axis). The datapoint in the scatterplot also has a colour depending on which population it belongs to.

I have written code that produces the graph I want, showing each population as a different colour on the scatterplot. What I need to do now is have each of the samples datapoints as a colour-gradient, with the colour intensity depending on the age of the sample.

For example, a sample from population A might be represented by the colour green. A very old sample might be dark green, while a more recent sample would be light green.

Does anyone have any idea how to do this? I have tried and have had little luck.

Sorry for the long post, but I hope I've provided all that is needed.

Code:

PopData <- data.frame ("Group" = apd$Group, 
                   "Lat" = apd$Latitude, 
                     "Lon" = apd$Longitude,
                       "Age" = apd$MDate)

satmap = get_googlemap(center = c(lon = 25, lat = 55), 
                   scale = 2, size = c(440, 440), zoom = 3, 
                      extent='device', color="color", maptype = "hybrid")


map = ggmap(satmap)

map + geom_point(data = points, aes(x=Lon, y=Lat, colour = Group))
                  + geom_jitter(width = 0.2, height = 0.2) 
                    + xlab("Longitude") + ylab("Latitude") 
                      + ggtitle("graph")
Luddo
  • 23
  • 3
  • It would help if you could [produce a minimal dataset](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Roman Oct 10 '18 at 12:13

0 Answers0