1
votes

Using this data frame, I attempted to create a simple line graph using the following code:

crypto_data<-
  crypto_data %>% gather(Cryptocurrencies, USD_Exchange, -Date)

ggplot(data = crypto_data) +
  geom_line(aes(x = Date, y = USD_Exchange, colour = Cryptocurrencies))

This produced the, apparently, well known error.

Revisit: geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?

I am aware that this question has been addressed most notably here:

ggplot2 line chart gives "geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?"

However, I am graphing more than a single variable.(Even though the data on the Litecoin USD exchange rate only starts at a later date it takes the value of zero prior to its introduction) I have also been mindful of stipulating the groups within aes() in ggplot (see the code). The command produces a graph with the correct axis lables and key, but a blank plotregion.

Does anyone see any obvious errors or perhaps have a solution? Thank you in advance.

1
I see this is your first Question on Stack Overflow, welcome! Please provide some code so we can see what you have tried and better understand the context of your question, which in turn will help us out to help you. Also see How To ask on how to ask better question which lead to better answers. Note that StackOverflow is not a coding service, we won't work out your assignments.Raymond
Instead of showing the code in a screenshot, paste it into your question directly. It makes your question more easy to readRaymond
Hi Raymond, thanks so much! I have tried to be as specific as possible and am also aware that StackOverflow will not serve the purpose of working out any assignments :)Schalkie
I have pasted the code directly into the question so you can see what I have tried to achieve.Schalkie

1 Answers

2
votes

Thanks for the edit suggestion, have found a solution!

crypto_data <-
crypto_data %>% gather(Cryptocurrencies, USD_Exchange, -Date)
ggplot(data=crypto_data) +
geom_line(aes(x=as.numeric(Date), y = USD_Exchange, colour = Cryptocurrencies)

Just had to make the Date variable (that was a factor variable) numeric...