映射R中的可变层数

时间:2019-06-19 22:39:14

标签: r plot geospatial tmap

我对R相对较新,并且正在构建一个小型应用程序,该应用程序根据用户使用R的tmap库选择的图层来映射数据。但是,当这些图层的名称根据选择而变化时,我不确定如何显示用户选择的所有图层。任何帮助深表感谢!

# Base layer
base_map_layer = tm_shape(base_data) + tm_fill()
maps = c(base_map_layer)

# Generate new layers based on what the user has selected
if(condition 1){
...
maps = append(maps, map_layer_2)
}

if(condition n){
...
maps = append(maps, map_layer_n)
}

# Right now I want to sum whatever layers are in the list I've created to 
# display them together:
# base_map + whatever additional layers the user has selected
sum(maps) 
# However, this returns 'Error in sum: invalid 'type' (list) of argument'

0 个答案:

没有答案