R: How to create multiple maps (rworldmap) using apply?

回眸只為那壹抹淺笑 提交于 2019-12-02 09:58:29

You are close.

Add this to save one plot per column.

#put column names to plot in a vector
col_names <- names(df)[1:6]


lapply(col_names, function(x) {
  #opens device to store pdf
  pdf(paste0(x,'.pdf'))
  #plots map
  mapCountryData(spdf, nameColumnToPlot=x)
  #closes created pdf 
  dev.off()
})
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!