-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from AlissonRP/freq2x2
Release 0.3
- Loading branch information
Showing
30 changed files
with
369 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v1 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v1 | ||
with: | ||
extra-packages: rcmdcheck | ||
|
||
- uses: r-lib/actions/check-r-package@v1 | ||
|
||
- name: Show testthat output | ||
if: always() | ||
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true | ||
shell: bash | ||
|
||
- name: Upload check results | ||
if: failure() | ||
uses: actions/upload-artifact@main | ||
with: | ||
name: ${{ runner.os }}-r${{ matrix.config.r }}-results | ||
path: check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export("%>%") | ||
export(as_tabyl) | ||
export(pdf1_freq.tbl) | ||
export(pdf1_freq.tbl2) | ||
export(pdf1_na) | ||
export(pdf1_summary) | ||
export(pdf1_tbl) | ||
export(pdf1_tbl_freq) | ||
export(pdf1_tbl_freq2) | ||
export(untabyl) | ||
importFrom(janitor,as_tabyl) | ||
importFrom(janitor,untabyl) | ||
importFrom(magrittr,"%>%") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' pdf1_freq.tbl | ||
#' | ||
#' this is a very simple frequency table generator | ||
#' | ||
#' | ||
#' @param obj Object used to create the table. Data frame, list or environment | ||
#' (or object coercible by as.data.frame to a data frame) | ||
#' @param tit Title for the table, write in string format | ||
#' @param v Variable that you want the table (not written in string format) | ||
#' @export | ||
pdf1_freq.tbl <- function(obj, v, tit) { | ||
stop("Esta função foi renomeada, use pdf1_tbl_freq") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
#' pdf1_freq.tbl | ||
#' pdf1_freq_tbl | ||
#' | ||
#' this is a very simple frequency table generator | ||
#' | ||
#' | ||
#' @param obj Object used to create the table. Data frame, list or environment | ||
#' (or object coercible by as.data.frame to a data frame) | ||
#' @param tit Title for the table, write in string format | ||
#' @param v Variable that you want the table (not written in string format) | ||
#' @param var Variable that you want the table (not written in string format) | ||
#' @param ... Other arguments | ||
#' @examples | ||
#' iris %>% | ||
#' mypdf1::pdf1_freq.tbl(Species, "title") %>% | ||
#' mypdf1::pdf1_tbl_freq(Species) %>% | ||
#' mypdf1::pdf1_tbl(" You can combine this function too!") | ||
#' @export | ||
pdf1_freq.tbl <- function(obj, v, tit) { | ||
pdf1_tbl_freq <- function(obj, var) { | ||
obj %>% | ||
dplyr::count({{ v }}) %>% | ||
dplyr::mutate(`Frequência Relativa` = prop.table(n) %>% round(3)) %>% | ||
dplyr::rename(`Frequência Absoluta` = n) %>% | ||
janitor::adorn_totals("row") | ||
dplyr::count({{ var }}) %>% | ||
dplyr::mutate(`relative_frequency` = prop.table(n) %>% round(3)) %>% | ||
dplyr::rename(`abosulute_frequency` = n) %>% | ||
janitor::adorn_totals("row") |> | ||
dplyr::tibble() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#' @importFrom janitor untabyl | ||
#' @export | ||
janitor::untabyl | ||
|
||
#' @importFrom janitor as_tabyl | ||
#' @export | ||
janitor::as_tabyl | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#library(hexSticker) | ||
#imgurl <- system.file("figures/teste.png", package="mypdf1") | ||
#(sticker(imgurl, package="mypdf1", p_size=20, s_x=1, s_y=.75, s_width=.55, | ||
# h_fill="#E7EDF0", h_color="#135389",p_color = "#135389")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#' pdf1_summary() | ||
#' | ||
#' this is a very summary generator | ||
#' | ||
#' | ||
#' @param obj Object used to create the table. | ||
#' | ||
#' `data.frame`, `list` or environment | ||
#' (or object coercible by `as.data.frame` to a `data.frame`) | ||
#' | ||
#' @param na_rm option to remove `NA` from variables | ||
|
||
#' @examples | ||
#' mtcars |> | ||
#' mypdf1::pdf1_summary() | ||
#' | ||
#' airquality |> mypdf1::pdf1_summary(na_rm = FALSE) | ||
#' | ||
#' iris |> mypdf1::pdf1_summary() | ||
#' @export | ||
pdf1_summary <- function(obj, na_rm = TRUE) { | ||
|
||
char <- obj |> | ||
dplyr::select(where((is.character))) |> # dumb i know | ||
ncol() | ||
fac <- obj |> | ||
dplyr::select(where((is.factor))) |> # dumb i know | ||
ncol() | ||
if ((char + fac) != 0) { | ||
warning("string and factors variables were removed for calculations")} | ||
obj <- obj |> | ||
dplyr::select(where(is.numeric)) | ||
if( na_rm== TRUE & any(is.na(obj))){ | ||
warning("Your dataframe has NA, they will be removed from calculations \n use na_rm = FALSE if you want to keep them") | ||
} | ||
|
||
|
||
funs <- c(mean = mean, median = median, sd = sd, min = min, max = max) | ||
args <- list(na.rm = na_rm) | ||
obj |> | ||
purrr::map_df(~ funs %>% | ||
purrr::map(purrr::exec, .x, !!!args), .id = "variable") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
#' pdf1_tbl | ||
#' | ||
#'this is a very simple table generator | ||
#' this is a very simple table generator | ||
#' | ||
#' | ||
#' @param obj Object used to create the table. Data frame, list or environment | ||
#' (or object coercible by as.data.frame to a data frame) | ||
#' @param tit Title for the table, write in string format | ||
#' @param format Format of table, write in string format. Possible values are latex, html. | ||
#' The value of this argument will be automatically determined if the function is called within a knitr document. | ||
#' @param code If you want the table code to appear in the console, put code=TRUE, the default is FALSE, you can combine with format. | ||
#' Remember that by default the format is html | ||
#' @param obj Object used to create the table. | ||
#' | ||
#' `data.frame`, `list` or environment | ||
#' (or object coercible by `as.data.frame` to a `data.frame`) | ||
#' @param title Title for the table, write in string format | ||
#' @param format Format of table, write in string format. Possible values are `"latex"`, "`html`". | ||
#' @param code If you want the table code to appear in the console, put `code=TRUE`, you can combine with `format`. | ||
#' @param ... Other arguments | ||
#' @note Remember that by default the format is `"html"` | ||
#' | ||
#' The default of `code` is `FALSE` | ||
#' | ||
#'The value of `format` will be automatically determined if the function is called within a knitr document | ||
#' @examples | ||
#'iris %>% | ||
#' dplyr::group_by(Species) %>% | ||
#' dplyr::summarise(mean=mean(Sepal.Length)) %>% | ||
#' mypdf1::pdf1_tbl("THIS FUNCTION IS SO INCREDIBLE!") | ||
#' iris %>% | ||
#' dplyr::group_by(Species) %>% | ||
#' dplyr::summarise(mean = mean(Sepal.Length)) %>% | ||
#' mypdf1::pdf1_tbl("THIS FUNCTION IS SO INCREDIBLE!") | ||
#' | ||
#' mtcars |> | ||
#' dplyr::group_by(carb) |> | ||
#' dplyr::summarise(sd = sd(wt)) |> | ||
#' mypdf1::pdf1_tbl() | ||
#' @export | ||
pdf1_tbl=function(obj,tit,format=NULL,code=F,...){ | ||
if(code==T){ | ||
pdf1_tbl <- function(obj, title = "", format = NULL, code = F, ...) { | ||
if (code == T) { | ||
obj %>% | ||
knitr::kable(caption=tit,align = "c",format=format) | ||
} else{ | ||
knitr::kable(caption = title, align = "c", format = format) | ||
} else { | ||
obj %>% | ||
knitr::kable(caption=tit,align = "c",format=format) |> | ||
knitr::kable(caption = title, align = "c", format = format) |> | ||
kableExtra::kable_classic(latex_options = "HOLD_position") | ||
|
||
} | ||
} |
Oops, something went wrong.