acstat231-f23 / blog-potterwatch

John Joire and Sarah Fatihi
https://acstat231-f23.github.io/blog-potterwatch/
0 stars 0 forks source link

figured out title for animated ggplot #5

Open katcorr opened 10 months ago

katcorr commented 10 months ago

@johnjoire

This works for me:

labs(title="{names_for_plotting |> filter(order==closest_state) |> distinct(var_you_want) |> pull(var_you_want)}")

Note the addition of distinct() (and replace "var_you_want" with the name of the variable). I figured this out by taking a look at the dataset produced. There were multiple rows for a given order, so essentially the title was feeding it a vector of length > 1. Using distinct will reduce it to one observation, so that pull just grabs one string.