我试图用它的数据作为填充来绘制一个shapefile。在尝试此操作时,我不幸地遇到了错误Aesthetics must be either length 1 or the same as the data (8112701): fill。
我的数据是一个284个长的SpatialPolygonsDataFrame,格式是
nations
@data
$OBJECTID (numeric)
$CNTRY_NAME (chr)
$CNTRY_CODE (chr)
$BPL_CODE (chr)
$deaths (numeric)
$cases (numeric)
@polygons
list of all polygons我试图使用的代码是:
ggplot() +
geom_polygon(data=nations, aes(x=long,y=lat,group=group,fill=nations@data$cases)) +
theme_void()回溯是
1. base `<fn>` (x)
2. ggplot2:::print.ggplot(x)
4. ggplot2:::ggplot_build.ggplot(x)
5. ggplot2 by)layer(function(l, d) l$compute_aesthetics(d, plot))
6. ggokit2 f(l= layers[[i]], d=date[[i]]])
7. l$compute_aestehetics(d, plot)
8. ggplot2 f(..., self=self)
9. ggplot2:::check_aesthetics(evaled, n)
Error in check_aesthetics(evaled, n)https://stackoverflow.com/questions/71709463
复制相似问题