[R-br] Plotar mapa por fator categórico

Éder Comunello comunello.eder em gmail.com
Terça Abril 21 17:44:44 BRT 2015


Leonardo, boa tarde!

Fiquei na dúvida quanto ao uso de as.ordered() e rodei um pequeno teste.
Parece funcionar do mesmo modo que com as.factor().

### <code r>
getwd()
url0  <- "
ftp://geoftp.ibge.gov.br/malhas_digitais/municipio_2007/escala_2500mil/proj_geografica_sirgas2000/uf/mt/51mu2500gsr.zip
"
bName <- sub(".zip$", "", basename(url0))

setInternet2(FALSE) ### download a partir de ftp no RStudio Windows
if (!file.exists(basename(url0))) download.file(url0, dest=basename(url0),
mode="wb")
unzip(basename(url0), list=T) ### conteúdo do zip
unzip(basename(url0))

require(rgdal)
mt <- readOGR(dsn=paste0(bName,".shp"), layer=bName, encoding="latin1")
str(mt, max=2)

plot(mt)
head(mt em data)
n <- nrow(mt em data); n

set.seed(756); x <- sample(LETTERS[1:3], size = n, replace=T)
mt em data$X1 <- as.factor(x)
mt em data$X2 <- as.ordered(x)

str(mt em data)
head(mt em data)
spplot(mt, "X1", col.regions=heat.colors(3))
spplot(mt, "X2", col.regions=heat.colors(3))
### </code>


Éder Comunello <c <comunello.eder em gmail.com>omunello.eder em gmail.com>
Dourados, MS - [22 16.5'S, 54 49'W]
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20150421/390ef499/attachment.html>


Mais detalhes sobre a lista de discussão R-br