0

I've been trying to reduce the length. like that

gapminder%>%
    filter(c(continent=="Kuwait"&"Saudi Arabia"&"Iraq"&"Iran"&"Korea, Rep."&"China"&"Japan"))%>%
    ggplot(aes(year,gdpPercap,col=country))+
    geom_point()+
    geom_line()

Error in continent == "Kuwait" & "Saudi Arabia" : 오로지 숫자, 논리, 또는 복소수 유형에 대한 연산들만 가능합니다

gapminder%>%
    filter(c(continent=="Kuwait"|"Saudi Arabia"|"Iraq"|"Iran"|"Korea, Rep."|"China"|"Japan"))%>%
    ggplot(aes(year,gdpPercap,col=country))+
    geom_point()+
    geom_line()

Error in continent == "Kuwait" | "Saudi Arabia" : 오로지 숫자, 논리, 또는 복소수 유형에 대한 연산들만 가능합니다

gapminder%>%
    filter(c(continent=="Kuwait","Saudi Arabia","Iraq","Iran","Korea, Rep.","China","Japan"))%>%
    ggplot(aes(year,gdpPercap,col=country))+
    geom_point()+
    geom_line()

에러: Argument 2 filter condition does not evaluate to a logical vector

It didn't work at all. how can i reduce the length of this calculation as using %>% I need help Thank you

pogibas
  • 27,303
  • 19
  • 84
  • 117
이승우
  • 29
  • 2

1 Answers1

1

Try this if this what you want:

gapminder%>%
  filter(country %in% c("Kuwait","Saudi Arabia","Iraq","Iran","Korea, Rep.","China","Japan"))%>%
  ggplot(aes(year,gdpPercap,col=country))+
  geom_point()+
  geom_line()

enter image description here

Zhiqiang Wang
  • 6,206
  • 2
  • 13
  • 27