I have a GIS vector file containing multiple attribute columns, such as t1, t2, t3, up to t8. My objective is to create individual plots for each attribute column within a panel display. Despite my attempts using terra, ggplot, and tidyterra, I consistently encounter errors during the process. I am not able to loop over with column names. aes fill is not taking column names and considering it as a discrete variable. Any assistance in resolving this challenge would be greatly appreciated.
grids = vect('5k_grid_scenarios.gpkg')
grids = grids %>%
select(t1:t8)
p = c()
for (i in names(grids)){
plot =
grids %>%
autoplot(aes(fill = i))+
scale_fill_whitebox_c(palette = "pi_y_g")
p[[i]] =plot
}
ggarrange(p)

aes(fill = .data[[i]])to refer to the column with nameI. Additionally I would suggest to uselapplyto create your list of plots, e.g. something likep <- lapply(names(grids), \(i) { grids |> autoplot(aes(fill = .data[[i]])) + ... }). For more help please provide a minimal reproducible example.