I'm quite new to R and I've been working at this problem for some time and could use some help. I have a CSV file (called cleaned_doc) which contains the rating and percent of a product sold per country, I would like to compare 2 countries in a faceted scatterplot with 2 facets for all of the product sold in those particular countries of origin.
When I try doing it like this
ggplot(data = cleaned_doc, aes(Percent, Rating)) +
geom_point() +
labs( y = "Rating", x = "Percent") +
facet_grid( ~ Origin )
I get faceted scatter plots for all the countries listed. However I just want to compare 2 (for this example I picked Germany and France) there are more components I want to add later but those are mainly aesthetics so I just want to keep it simple for now. Based on what I've seen on Stackoverflow & other places I tried doing it like this
countries <- gather(cleaned_doc, key="measure", value="value", c(Origin["Germany"], Origin["France"]))
answer2 <- ggplot(data = cleaned_doc, aes(Percent, Rating)) +
geom_point() +
labs( y = "Rating", x = "Percent") +
facet_grid(~ countries )
However then I get the following error
Error: At least one layer must contain all faceting variables: `countries`.
* Plot is missing `countries`
* Layer 1 is missing `countries`
and I'm really not sure what that means and what I'm doing wrong. so I would really appreciate any help.