<div dir="ltr">Marcelo, <div><br><div>Seu código não atende à diretriz deste grupo em <a href="http://www.leg.ufpr.br/r-br-guia">Guia de Postagem no R-br</a>, em particular, a solicitação de fornecer o CMR (<i>código mínimo reproduzível</i>).</div></div><div>As chances de você obter respostas são maiores quando essa recomendação é seguida.</div><div><br></div><div>HTH</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 29, 2020 at 9:05 AM Marcelo Magalhães por (R-br) <<a href="mailto:r-br@listas.c3sl.ufpr.br">r-br@listas.c3sl.ufpr.br</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="PT-BR"><div class="gmail-m_8094230257664777765WordSection1"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Prezados e Prezadas,</p><p class="MsoNormal"><u></u> <u></u></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Estou trabalhando com o IVS (Índice de Vulnerabilidade Social), mais precisamente com as UDHs (Unidades de Habitação) para o Município de Jaboatão dos Guararapes - PE. A base Completa + Shapefiles estão no site do Ipea (<a href="http://ivs.ipea.gov.br/index.php/pt/biblioteca" target="_blank"><span style="color:rgb(0,119,145);text-decoration:none">http://ivs.ipea.gov.br/index.php/pt/biblioteca</span></a>). Gostaria de fazer um mapa do Índice de Vulnerabilidade Social do Município para saber quais as localidades mais vulneráveis.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Tentei unir pelo código do município e pela variável UDH_Atlas no shapefile e udh e travei.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Ao que parece:<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">1. UDHs são colocados como "strings" pelo R, ao colocar a função as.numeric(), há uma mudança nas linhas.<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">2. UDHs são coordenadas únicas (não se separam em Long. e Lat.), ou temos que separá-las em Long e Lat?<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Agradeço desde já a ajuda,<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Marcelo Nery Magalhães<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Script:<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Bibliotecas<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">library(ggplot2)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">library(rgdal)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Shape<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Jab<-readOGR("C:/Users/usuario/Documents/IVS", "UDHs_RM_Todas")<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">head(Jab@data)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Transformando string em numérico<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Jab$UDH_ATLAS<-as.numeric(Jab$UDH_ATLAS)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Base de dados/tabela<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">ivs<-read.csv("C:/Users/usuario/Documents/IVS/jab.csv", sep = ";", head=T, dec = ",")<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">head(ivs)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">ivs<-na.omit(ivs)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(Jab@data)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(ivs)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Transformando os nomes das variáveis em um só para cada objeto<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(ivs)[12]<-c("Cod_mun_6")<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(Jab)[1]<-c("udh") # tentei criar uma chave com essa variável, já que com o código do município não estava funcionando<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(Jab)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(ivs)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Ordenando<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">ivs<-ivs[order(ivs$Cod_mun_6),]<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">Jab<-Jab@data[order(Jab$Cod_mun_6),]<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">head(ivs)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">head(Jab)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Combinando através da Chave do Código do Município<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">j<-merge(Jab,ivs,by.y="Cod_mun_6") # Houve problema ao criar “j”<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">head(j)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">dim(Jab)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">dim(ivs)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">dim(j)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">fortify(Jab)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">j.f<-fortify(Jab,region="udh")<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)"><u></u> <u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">j$ivs<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Categorizando<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">j$ivscat<-cut(j$ivs, breaks = c(0,0.200,0.300,0.400,0.500,1), labels=c("0 a 0,200 - Muito Baixa", "0,200 a 0,300 - Baixa", "0,300 a 0,400 - Média", "0,400 a 0,500 - Alta", "0,500 a 1 - Muito Alta"), include.lowest=T)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(j)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">names(j.f)<u></u><u></u></span></p><p style="background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">#Problema: udh não possui latitude e lobgitude (como fazer, então?)<u></u><u></u></span></p><p style="margin-right:0cm;margin-bottom:7.9pt;margin-left:0cm;background:white"><span style="font-size:10pt;font-family:Helvetica,sans-serif;color:rgb(41,48,59)">jabo<-merge(j, j.f, by.y="udh")<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></div>
_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br>
</blockquote></div>