Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
rely on purrr instead of purrrlyr
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Aug 29, 2019
1 parent e1da2cc commit f637a3c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -30,7 +30,7 @@ Imports:
groupedstats,
jmv,
magrittr (>= 1.5),
purrrlyr,
purrr,
rlang (>= 0.4.0),
stats,
stringr,
Expand Down
5 changes: 4 additions & 1 deletion NAMESPACE
Expand Up @@ -19,6 +19,7 @@ importFrom(WRS2,rmmcp)
importFrom(dplyr,everything)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
importFrom(dplyr,group_nest)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_at)
importFrom(dplyr,mutate_if)
Expand All @@ -36,7 +37,7 @@ importFrom(jmv,anovaRMNP)
importFrom(magrittr,"%$%")
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(purrrlyr,by_row)
importFrom(purrr,map)
importFrom(rlang,"!!")
importFrom(rlang,"%|%")
importFrom(rlang,"%||%")
Expand All @@ -59,6 +60,8 @@ importFrom(tibble,enframe)
importFrom(tibble,rowid_to_column)
importFrom(tibble,tibble)
importFrom(tidyr,gather)
importFrom(tidyr,nest)
importFrom(tidyr,separate)
importFrom(tidyr,spread)
importFrom(tidyr,unnest)
importFrom(utils,combn)
39 changes: 25 additions & 14 deletions R/pairwise_comparisons.R
Expand Up @@ -51,15 +51,16 @@
#' }
#'
#' @importFrom dplyr select rename mutate mutate_if everything full_join vars
#' @importFrom dplyr group_nest
#' @importFrom stats p.adjust pairwise.t.test na.omit aov TukeyHSD var sd
#' @importFrom stringr str_replace
#' @importFrom WRS2 lincon rmmcp
#' @importFrom tidyr gather spread separate
#' @importFrom tidyr gather spread separate unnest nest
#' @importFrom rlang !! enquo as_string ensym
#' @importFrom tibble as_tibble rowid_to_column enframe
#' @importFrom jmv anovaNP anovaRMNP
#' @importFrom forcats fct_relabel
#' @importFrom purrrlyr by_row
#' @importFrom purrr map
#'
#' @examples
#'
Expand Down Expand Up @@ -472,25 +473,35 @@ pairwise_comparisons <- function(data,
.predicate = is.factor,
.funs = ~ as.character(.)
) %>%
purrrlyr::by_row(
.d = .,
..f = ~ specify_decimal_p(
x = .$p.value,
k = k,
p.value = TRUE
),
.collate = "rows",
.to = "label",
.labels = TRUE
) %>%
dplyr::mutate(.data = ., rowid = dplyr::row_number()) %>%
dplyr::group_nest(.tbl = ., rowid) %>%
dplyr::mutate(
.data = .,
label = data %>%
purrr::map(
.x = .,
.f = ~ specify_decimal_p(x = .$p.value, k = k, p.value = TRUE)
)
)

# unnesting the dataframe
if (utils::packageVersion("tidyr") <= "0.8.9") {
df %<>%tidyr::unnest(.)
} else {
df%<>% tidyr::unnest(., cols = c(data, label))
}


# formatting label
df %<>%
dplyr::mutate(
.data = .,
p.value.label = dplyr::case_when(
label == "< 0.001" ~ paste("list(~italic(p)<=", "0.001", ")", sep = " "),
TRUE ~ paste("list(~italic(p)==", label, ")", sep = " ")
)
) %>%
dplyr::select(.data = ., -label)
dplyr::select(.data = ., -label, -rowid)

# return
return(tibble::as_tibble(df))
Expand Down
18 changes: 12 additions & 6 deletions codemeta.json
Expand Up @@ -8,10 +8,10 @@
"description": "Multiple pairwise comparison tests for one-way\n analysis of variance for both between-subjects and within-subjects\n designs. Currently, it supports only the most common types of\n statistical analyses and tests: parametric (Welch's and Student's\n t-test), nonparametric (Durbin-Conover test and\n Dwass-Steel-Crichtlow-Fligner test), robust (Yuen’s trimmed means test).",
"name": "pairwiseComparisons: Multiple Pairwise Comparison Tests",
"codeRepository": "https://github.com/IndrajeetPatil/pairwiseComparisons",
"relatedLink": "https://indrajeetpatil.github.io/pairwiseComparisons/",
"relatedLink": ["https://indrajeetpatil.github.io/pairwiseComparisons/", "https://CRAN.R-project.org/package=pairwiseComparisons"],
"issueTracker": "\n https://github.com/IndrajeetPatil/pairwiseComparisons/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.0",
"version": "0.1.0.9000",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -207,15 +207,15 @@
},
{
"@type": "SoftwareApplication",
"identifier": "purrrlyr",
"name": "purrrlyr",
"identifier": "purrr",
"name": "purrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrrlyr"
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
{
"@type": "SoftwareApplication",
Expand Down Expand Up @@ -318,5 +318,11 @@
"url": "https://CRAN.R-project.org/package=pairwiseComparisons"
}
],
"readme": "https://github.com/IndrajeetPatil/pairwiseComparisons/blob/master/README.md"
"readme": "https://github.com/IndrajeetPatil/pairwiseComparisons/blob/master/README.md",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
}
}

2 comments on commit f637a3c

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/pairwise_comparisons.R:158:1: style: functions should have cyclomatic complexity of less than 15, this has 19.

pairwise_comparisons <- function(data,
^

R/pairwise_comparisons.R:489:8: style: Put spaces around all infix operators.

df %<>%tidyr::unnest(.)
       ^~~~~

R/pairwise_comparisons.R:491:7: style: Put spaces around all infix operators.

df%<>% tidyr::unnest(., cols = c(data, label))
     ~^

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/pairwise_comparisons.R:158:1: style: functions should have cyclomatic complexity of less than 15, this has 19.

pairwise_comparisons <- function(data,
^

R/pairwise_comparisons.R:489:8: style: Put spaces around all infix operators.

df %<>%tidyr::unnest(.)
       ^~~~~

R/pairwise_comparisons.R:491:7: style: Put spaces around all infix operators.

df%<>% tidyr::unnest(., cols = c(data, label))
     ~^

Please sign in to comment.