R/acidente_cnae.R

Defines functions acidente_cnae

Documented in acidente_cnae

#' Function acidente_cnae
#'
#' This function returns 
#' @param cnae vector of Brazilian Code of Economic Activity corresponding to the ISIC

#' @keywords labor accidents
#' @import jsonlite
#' @import stringr
#' @return A data.frame with 7 variables with the information available.
#' @examples
#' Extract information from chemical, pharmaceutical and rubber industries.
#' df<-acidente_cnae(cnae=c(20,21,22)) 

#' @export

acidente_cnae<-function(cnae){
url<-"http://dadosabertos.dataprev.gov.br/opendata/act10/formato=json"
a<-readLines(file(url, encoding="ISO-8859-1"), warn=FALSE)
b<-fromJSON(a)
c<-b$nodes$node
cnae<-paste0(cnae,collapse = "|")
cnae<-paste0("^(",cnae,")")
c<-c[str_which(c$CNAE,cnae),]
return(c)
}
jjesusfilho/trabalho documentation built on Oct. 31, 2021, 10:20 p.m.