I have two dataframes, one that I used in the function below as the input and another one called abbreviations that contains two columns: the abrreviations for European cities(Abvr) and full names of the cities(Name).
What I want to do is add a dynamic title to my plot that looks for the full name of the city in the abbreviations dataframe. This name called "X" I then want to use in my function below. I'm struggling to find a way to add this. when I put in ggtitle(paste0("Storms in ",abbreviations$name))
It just chooses the first value of the column which is a random city, instead of the one that matches the city in my other dataframe.
I have the code below:
plot_by_city<- function(dataframe, city_name, color="red"){
data1 <- filter(dataframe, city == city_name)
ggplot(data = data1, aes(x= scale, y= injuries)) +
geom_point(position= "jitter",shape=23, fill= color, color="black", size=3)+
ggtitle(paste0("Storms in ",X))
}
A possible input would be plot_by_city((Dataframe,"AMS", "tan")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…