0

I have a data set in R.

Sample dataset

location longitude latitude
loc1     24.600    67.524
loc1     24.600    67.535
loc2     28.478   -17.789
loc3     30.654    12.397
loc3     30.654    12.397
loc3     30.654    12.397

This is the code I've been trying with.

library(ggplot2)
data <- read.csv('a.csv')
ggplot(data, aes(year, value, group = 1)) + geom_line(aes(color = coalgrade)) + labs(x = "year", y = "value") + facet_wrap(~location + coalgrade)

How can I arrange the facets to be in order based on longitude?

  • 2
    The data you show has columns `location`, `longitude`, and `latitude`. The data you are plotting has columns `year`, `value`, and `coalgrade`, `location`. You don't show or mention any sort of overlap. Is there a way to connect them? Do you need help connecting them? Or are they already joined and you only need help reordering facets? – Gregor Thomas Apr 27 '20 at 17:12
  • What are you trying to do here? Could you draw an example of what you are trying to achieve? If you have more data, you could try: `ggplot(data, aes(x = latitude, y = longitude)) + geom_line() + labs(title = "Title here", x = "Latitude", y = "Longitude") + facet_wrap(~location)` –  Apr 28 '20 at 08:21

0 Answers0