ipeadata-lab / ipeaplot

ipeaplot: criando graficos no padrão editorial do Ipea
https://ipeadata-lab.github.io/ipeaplot/
Other
1 stars 0 forks source link

Erro quando uso `insert_text()` #10

Closed cavalcanti1985 closed 11 months ago

cavalcanti1985 commented 11 months ago

Quando uso o insert_text() sem definição do "label" parece uma mensagem de erro, como no exemplo abaixo:

## Exemplo 1
graph <- abjData::pnud_uf %>%
  filter(substr(uf,1,1) == "3") %>%
  select(1:4)

# Create a discrete scatter plot with 'mpg' on the x-axis, 'wt' on the y-axis, and filled by 'quantile'
# Use the 'scale_ipea()' function to apply the IPEA discrete fill scale
ggplot(data = graph, aes(x = ufn,
                         y = espvida,
                         fill = as.character(ano))) +
  geom_bar(stat="identity", width= 0.5) +
  scale_fill_ipea(discrete = T) +
  labs(x="",
       y="",
       fill = "",
       title="GRÁFICO 5",
       subtitle="Indicadores de infraestrutura das escolas - capitais regionais do Nordeste (2018)",
       caption = 'Fonte: ipea') +
  theme_ipea(legend.position = 'bottom', geom = 'bar', position = "dodge") + 
  insert_text()
Error in `ggplot_add()`:
! Can't add `insert_text()` to a <ggplot> object
ℹ Did you forget to add parentheses, as in `insert_text()()`?
Run `rlang::last_trace()` to see where the error occurred.

Não seria importante personalizar a mensagem de erro e pedir que se preencha o atributo "label".

PedroJorge7 commented 11 months ago

Fiz um fix para retornar numa mensagem de erro

  if(is.null(label)){
    stop("Error: argument 'label' is missing, with no default")
  } 
cavalcanti1985 commented 11 months ago

Ótimo, Pedro.