Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adicionar mais exemplos de rotinas #28

Open
temospena opened this issue Feb 1, 2021 · 1 comment
Open

adicionar mais exemplos de rotinas #28

temospena opened this issue Feb 1, 2021 · 1 comment

Comments

@temospena
Copy link
Owner

temospena commented Feb 1, 2021

exemplo, para calcular feriados nacionais, incluindo carnaval

u = "https://date.nager.at/api/v2/publicholidays/"
feriados = data.frame()
for(i in 2020:2030){
  link = paste0(u, i, "/PT")
  feriados1 = jsonlite::fromJSON(link) %>% filter(global == TRUE) %>% select(date, localName, fixed, type)
  feriados = rbind(feriados,feriados1)
  rm(feriados1)
}
@temospena
Copy link
Owner Author

adicionar progress bar

library(progress)
pb <- progress_bar$new(
   format = "[:bar] :percent eta: :eta",
   total = 100, clear = FALSE, width= 80)

l = list()
for (j in 1:nrow(TRIPSgeo)){
   p = TRIPSgeo$route$features[[j]]$geometry
   # message("registo ", j)
   pb$tick()
   Sys.sleep(1 / 100)
   for (i in 1:nrow(p)){
      p$x[i]= p$coordinates[[i]][[1]]
      p$y[i]= p$coordinates[[i]][[2]]
      l[j] = st_as_sf(p, coords = c("x","y")) %>% st_combine() %>%  st_cast("LINESTRING")
   }
   TRIPSgeo$path[j] = l[j] 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant