temospena / Rnotebook

a compilation of R chunks
http://web.tecnico.ulisboa.pt/~rosamfelix/r/COMPILACAO.html
1 stars 0 forks source link

quartis ou outra classificação automática #20

Open temospena opened 4 years ago

temospena commented 4 years ago
library(dplyr)
PONTOS60$quartis <- ntile(PONTOS60$`Cic/Hora_2019`, 4)  %>% 
                      factor(labels=c("Q1","Q2","Q3","Q4"))
table(PONTOS60$quartis)
# Q1 Q2 Q3 Q4 
# 15 15 15 15
temospena commented 4 years ago
PONTOS60$quartis2 <- cut(
  PONTOS60$`Cic/Hora_2019`,
  breaks = c(0, 15, 30, 45, 100, max(PONTOS60$`Cic/Hora_2019`)),
  labels = c("0-15","15-30","30-45","45-90", ">100")
)
temospena commented 4 years ago

num mapa, classificar automaticamente

mapview(
  Trotinetas2019PontoHoras,
  zcol = "TrotinetasHora",
  at = quantile(Trotinetas2019PontoHoras$TrotinetasHora),
  lwd = 0.5,
  layer.name = "trotinetas/hora",
  label = Trotinetas2019PontoHoras$Local,
  popup = leafpop::popupTable(
    Trotinetas2019PontoHoras,
    row.numbers = F,
    feature.id = F
  )
)
temospena commented 3 years ago
PONTOS60$quartis2 <- cut(
  PONTOS60$`Cic/Hora_2019`,
  breaks = c(0, 15, 30, 45, 100, max(PONTOS60$`Cic/Hora_2019`)),
  labels = c("0-15","15-30","30-45","45-90", ">100")
)
RedeViaria$declive_class =  RedeViaria$declive %>% 
  cut(
    breaks = c(0, 3, 5, 8, 10, 20, Inf),
    labels = c("0-3: plano", "3-5: leve","5-8: médio", "8-10: exigente", "10-20: terrível", ">20: impossível"),
    right = F #para incluir o intervalo com 0-3] em vez de [
  ) 
temospena commented 2 years ago

usar este package maravilhoso? https://hughjonesd.github.io/santoku/tutorials/00-visualintroduction.html