给定“组ID”值,我需要获取2个值的所有置换
我有这个:
group id value
1 a
1 b
1 c
2 b
2 c
2 d
Run Code Online (Sandbox Code Playgroud)
并想要这个:
group id value1 value2
1 a b
1 a c
1 b a
1 b c
1 c a
1 c b
2 b c
2 b d
2 c b
2 c d
2 d b
2 d c
Run Code Online (Sandbox Code Playgroud) 我有一个形状文件,我想用 ggplot 将其发布在谷歌地图上,但是通过 geom_polygon(ggplot2) 发布会显示没有意义的线条
我的代码:
######## the shape file ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2015/Brasil/BR/
download.file("ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2015/Brasil/BR/br_municipios.zip",temp)
data <- unz(temp, "BRMUE250GC_SIR.shp")
data.shape<-st_read(data)
####### the map from ggmap
mapa_edital_guarulhos <- get_map(location="GUARULHOS-SP",zoom=11,color = "bw",
maptype = "roadmap")
mapa_edital_guarulhos_01<- ggmap(mapa_edital_guarulhos)
########## plotting with ggplot
mapa_edital_guarulhos1 <- mapa_edital_guarulhos_01 +
geom_polygon(aes(x=long,y=lat, group=group), data=shape.sp,
color='black',alpha=0)
Run Code Online (Sandbox Code Playgroud)
结果:
箭头显示的线条在我的图中没有意义,仅绘制相同间隔的形状:
plot(shape.sp,xlim=c(-47.25,-46.95),ylim=c(-23.1,-22.7))
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题吗?谢谢