我很习惯ggplot2,但没有那么多sf。我已经使用st_as_sf()将spatialpolygonsdataframe转换为sf,现在我正在尝试绘制它。为什么我的变量'test'是一个矩阵?我做错了什么?
class(wards)
[1] "sf" "data.frame"
names(wards)
[1] "wd16cd" "wd16nm" "lad16nm"
[4] "test" "2015_no2_total" "2020_no2_total"
[7] "2025_no2_total" "2030_no2_total" "2011_pm25_total"
[10] "2011_pm25_secondary" "2011_pm25_residual_salt" "2015_pm25_total"
[13] "2015_pm25_secondary" "2015_pm25_residual_salt" "2020_pm25_total"
[16] "2020_pm25_secondary" "2020_pm25_residual_salt" "2025_pm25_total"
[19] "2025_pm25_secondary" "2025_pm25_residual_salt" "2030_pm25_total"
[22] "2030_pm25_secondary" "2030_pm25_residual_salt" "geometry"
class(wards$test)
[1] "matrix"
ggplot(wards) +
+ geom_sf(aes(fill = test))
Error: Column `fill` must be a 1d atomic vector or a list
谢谢,詹姆斯