Skip to content

Commit

Permalink
remove stApply() 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Cazelles committed Jun 21, 2019
1 parent 3bb4dd3 commit 81cb0e6
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 161 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export(scaleWithin)
export(setColClass)
export(signifSymbols)
export(squaretize)
export(stApply)
export(substrBib)
export(whichIs)
export(wordCount)
Expand Down
19 changes: 9 additions & 10 deletions R/applyString.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
#' Kevin Cazelles
#'
#' @param x a character vector, or a vector to be coerced to a character vector.
#' @param FUN the function to be applied, see [base::lapply].
#' @param FUN the function to be applied, see [base::lapply()].
#' @param pos a vector indicating the elements position.
#' @param pattern a see [base::gregexpr].
#' @param ... argument to be passed to `gregexpr`.
#' @param pattern a pattern see [base::gregexpr()].
#' @param ... argument to be passed to [base::gregexpr()].
#'
#' @note
#' In case both `pos` or `pattern`, the latter is ignored.
#'
#' @return
#' A character vector.
#'
#' @importFrom magrittr %>% %<>%
#' @importFrom magrittr %>%
#' @export
#' @examples
#' applyString('cool', pos = 1:2, FUN = toupper)
#' applyString(c('cool', 'pro'), pattern = 'o', FUN = toupper)


applyString <- function(x, FUN, pos = NULL, pattern = NULL) {
if (!is.character(x))

if (!is.character(x))
x <- as.character(x)

if (!is.null(pos)) {
tmp <- strsplit(x, split = "")
tmp_fun <- function(x) {
x[pos] %<>% FUN
x[pos] <- FUN(x[pos])
paste(x, collapse = "")
}
out <- lapply(tmp, tmp_fun) %>% unlist
Expand All @@ -50,7 +50,6 @@ applyString <- function(x, FUN, pos = NULL, pattern = NULL) {
out <- apply(cbind(tmp_mth, tmp_inv), 1, FUN = reassemble, f = FUN)
}
}

out
}

Expand All @@ -61,7 +60,7 @@ reassemble <- function(x, f) {
sz <- length(char1) + length(char2)
out <- rep("", sz)
out[seq(1, sz, 2)] <- char2
if (sz > 1)
if (sz > 1)
out[seq(2, sz - 1, 2)] <- f(x[1L][[1L]])
paste(out, collapse = "")
}
2 changes: 1 addition & 1 deletion R/signifSymbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @examples
#' signifSymbols(.012)
#' signifSymbols(.008)
#' sapply(c(.2, .08, .04, .008, 0.0001), signifSymbols)
#' lapply(c(.2, .08, .04, .008, 0.0001), signifSymbols)

signifSymbols <- function(pvalue, thresholds = c(0.1, 0.05, 0.01, 0.001),
symbols = c(".", "*", "**", "***"), notsignif = "n.s.") {
Expand Down
65 changes: 0 additions & 65 deletions R/stApply.R

This file was deleted.

2 changes: 1 addition & 1 deletion docs/News.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 81cb0e6

Please sign in to comment.