Home > front end >  I want a line chart by year, but the code below does not produce same
I want a line chart by year, but the code below does not produce same

Time:09-30

gapminder %>% ggplot(aes(x = year, y = gdpPercap )) geom_line() theme_bw()

enter image description here

CodePudding user response:

You probably want to use group = country like this:

library(gapminder)
library(ggplot2)
library(dplyr)
gapminder %>% 
  ggplot(aes(x = year, y = gdpPercap, group = country))   
  geom_line()   
  theme_bw()

Created on 2022-09-29 with reprex v2.0.2

  •  Tags:  
  • r
  • Related