2021年3月31日星期三

Function in R that allows to control 2 variables in ggplot

Tourism <- function(...){    tour%>%       filter(Country %in% c(...))%>%      select(Country, `1995`:`2019`)%>%      gather(key = "Year", value="Dollars", -Country)%>%       ggplot(aes(x = Year, y = Dollars, colour = Country, group = Country))  +       geom_line() +geom_point() +        scale_y_log10(label=dollar) +       ggtitle("Tourism Dollars") + theme(plot.title = element_text(hjust = 0.5))  }  Tourism("Italy","Canada")  

I have this code working pretty fine. However I would like to update this function to allow the user to set not only the country, but also the year shown in the graph. enter image description here

https://stackoverflow.com/questions/66897862/function-in-r-that-allows-to-control-2-variables-in-ggplot April 01, 2021 at 10:59AM

没有评论:

发表评论