-
Notifications
You must be signed in to change notification settings - Fork 5
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 #3 from gbganalyst/englue
Added str_englue()
- Loading branch information
Showing
22 changed files
with
231 additions
and
28 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
^cran-comments.md$ | ||
^\.github$ | ||
^CRAN-SUBMISSION$ | ||
Rplot.png |
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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(length_omit_na) | ||
export(str_englue) | ||
export(str_extract_part) | ||
export(str_left) | ||
export(str_mid) | ||
export(str_right) | ||
export(str_rm_whitespace_df) | ||
export(str_split_extract) | ||
import(rlang) | ||
importFrom(dplyr,"%>%") | ||
importFrom(dplyr,across) | ||
importFrom(dplyr,mutate) | ||
importFrom(ggplot2,aes) | ||
importFrom(ggplot2,geom_histogram) | ||
importFrom(ggplot2,ggplot) | ||
importFrom(ggplot2,labs) | ||
importFrom(glue,glue) | ||
importFrom(stats,na.omit) |
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,15 @@ | ||
# What is New in *forstringr* | ||
|
||
## 0.1.1 (2023-04-10) | ||
|
||
- Added `str_englue()`, an alias of `rlang::englue()`. | ||
|
||
- Added meaningful error messages for all the functions in the forstringr package. | ||
|
||
## 0.0.1 (2022-08-29) | ||
|
||
Added package logo, `community_data` (data containing whitespaces), `length_omit_na()`, and `str_extract_part()` functions, and modified unit tests. | ||
|
||
## 0.0.0.9 (2022-07-20) | ||
|
||
The development version of forstringr is now on Githhub. | ||
The development version of forstringr is now on Githhub. |
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,29 @@ | ||
#' Dynamic plot labels using glue operators | ||
#' @description | ||
#' `str_englue()` helps you solve the labeling problem during plotting. For example, any value wrapped in `{ }` will be inserted into the string and it can also understands embracing, `{{ }}`, which automatically inserts a given variable name. | ||
# Suppress R CMD check note for glue package (not use but imported for rland) | ||
#' @importFrom glue glue | ||
#' @inheritParams rlang::englue | ||
#' @importFrom ggplot2 ggplot | ||
#' @importFrom ggplot2 aes | ||
#' @importFrom ggplot2 geom_histogram | ||
#' @importFrom ggplot2 labs | ||
#' @import rlang | ||
#' | ||
#' @seealso | ||
#' [rlang::englue()] | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' histogram_plot <- function(df, var, binwidth) { | ||
#' df |> | ||
#' ggplot(aes(x = {{ var }})) + | ||
#' geom_histogram(binwidth = binwidth) + | ||
#' labs(title = str_englue("A histogram of {{var}} with binwidth {binwidth}")) | ||
#'} | ||
|
||
#' iris |> histogram_plot(Sepal.Length, binwidth = 0.1) | ||
|
||
str_englue <- function(x, env, error_call, error_arg) englue(x, env = caller_env(), error_call = current_env(), error_arg = "x") | ||
|
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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
test_that("str_extract_part() returns only strings before the % sign", { | ||
expect_equal( | ||
str_extract_part(c("5%", "92%", "75%"), TRUE, "%"), | ||
str_extract_part(string = c("5%", "92%", "75%"), pattern = "%", before = TRUE), | ||
c("5", "92", "75") | ||
) | ||
}) | ||
|
||
test_that("str_extract_part() return only strings after -", { | ||
expect_equal( | ||
str_extract_part(c("Good-Morning", "Good-Afternoon"), FALSE, "-"), | ||
str_extract_part(string = c("Good-Morning", "Good-Afternoon"), pattern = "-", before = FALSE), | ||
c("Morning", "Afternoon") | ||
) | ||
}) |
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,7 @@ | ||
g <- function(var) str_englue("{{ var }}") | ||
|
||
|
||
test_that("str_englue() automatically inserts a given variable name using a glue operator {{}}", { | ||
expect_equal(g(cyl), "cyl") | ||
}) | ||
|
Oops, something went wrong.