Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
migconforto committed Aug 26, 2022
0 parents commit 65f868b
Show file tree
Hide file tree
Showing 34 changed files with 5,975 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
^renv$
^renv\.lock$
^PNADc\.table\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^\.github$
^README\.Rmd$
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Bug report or feature request
about: Describe a bug you've seen or make a case for a new feature
---

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on <https://stackoverflow.com/> or <https://community.rstudio.com/>.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading <https://www.tidyverse.org/help/#reprex>.

Brief description of the problem

```r
# insert reprex here
```
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Rproj.user
.Rhistory
.Rdata
.httr-oauth
.DS_Store
inst/doc
27 changes: 27 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Package: PNADc.table
Title: PNADc data tabulation
Version: 0.0.0.9000
Authors@R:
person("Miguel", "Conforto", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: Functions that return graphs and tables with already calculated PNADc data (mean, total and percentage).
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Imports:
fs,
ggplot2,
gt,
magrittr,
PNADcIBGE,
stats,
survey,
utils,
webshot
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2022
COPYRIGHT HOLDER: PNADc.table authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2022 PNADc.table authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(pnadc_download)
export(pnadc_graph)
export(pnadc_mean)
export(pnadc_porcent)
export(pnadc_total)
export(pnadc_tracks)
importFrom(ggplot2,facet_grid)
importFrom(ggplot2,geom_col)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,guide_axis)
importFrom(ggplot2,guide_legend)
importFrom(ggplot2,guides)
importFrom(gt,fmt_percent)
importFrom(gt,md)
importFrom(gt,sub_missing)
importFrom(gt,tab_header)
importFrom(gt,tab_options)
importFrom(gt,tab_source_note)
importFrom(magrittr,"%>%")
22 changes: 22 additions & 0 deletions PNADc.table.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
56 changes: 56 additions & 0 deletions R/baixa_pnadc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Download PNADc -------------------------------------------------------------
#' pnadc_download
#'
#' @description download the PNADc version and create a design directly on the computer.
#'
#' @param year The year you want to download. Must be a number between 2012 and the current year. It does not accept a vector of years.
#' @param quartile The quartile of the year you want to download. Must be a number between 1 and 4. It does not accept a vector of quartiles.
#' @param path Path of the local directory where the PNAD files are or where you want to save the data. If it does not exist, a new directory will be created.
#'
#' @export
#'
#' @examples pnadc_download(2019, 1)
pnadc_download <- function(year, quartile, path = NULL) {
webshot::install_phantomjs(force = T)
if (is.null(path)) {
if (file.exists(fs::path_home(paste("Design_PNADc", year, quartile, sep = "_"))) == T) {
print("This edition of the PNADc has already been downloaded and can be used.")
}
else {
design_PNADc <- PNADcIBGE::get_pnadc(year, quarter = quartile, design = T)

file <- paste("Design_PNADc", year, quartile, sep = "_")
save(design_PNADc, file = fs::path_home(file))
utils::globalVariables('design_PNADc', package = 'PNADc.table')
}
}
else {
if (file.exists(paste(path, "/Design_PNADc_", year, "_", quartile, sep = "")) == T) {
print("This edition of the PNADc has already been downloaded and can be used.")

save(path, file = fs::path_home(paste("path_PNADcTABLE", year, quartile, sep = "_")))
utils::globalVariables('design_PNADc', package = 'PNADc.table')
}
else {
if (file.exists(paste(path, "/PNADC_0", quartile, year, ".txt", sep = "")) == T) {
PNAD_txt <- paste(path, "/PNADC_0", quartile, year, ".txt", sep = "")
INPUT_sas <- paste(path, "/input_PNADC_trimestral.sas", sep = "")
pnadc <- PNADcIBGE::read_pnadc(PNAD_txt, INPUT_sas)
design_PNADc <- PNADcIBGE::pnadc_design(pnadc)

path <- paste(path, "/Design_PNADc_", year, "_", quartile, sep = "")
save(design_PNADc, file = path)
save(path, file = fs::path_home(paste("path_PNADcTABLE", year, quartile, sep = "_")))
utils::globalVariables('design_PNADc', package = 'PNADc.table')
}
else {
design_PNADc <- PNADcIBGE::get_pnadc(year, quarter = quartile, design = T)

path <- paste(path, "/Design_PNADc_", year, "_", quartile, sep = "")
save(design_PNADc, file = path)
save(path, file = fs::path_home(paste("path_PNADcTABLE", year, quartile, sep = "_")))
utils::globalVariables('design_PNADc', package = 'PNADc.table')
}
}
}
}
Loading

0 comments on commit 65f868b

Please sign in to comment.