### Install stringr Package Source: https://github.com/tidyverse/stringr/blob/main/README.md Installs the stringr package. It can be installed individually or as part of the tidyverse. ```r install.packages("tidyverse") # Alternatively, install just stringr: install.packages("stringr") ``` -------------------------------- ### Install RegExplain RStudio Addin Source: https://github.com/tidyverse/stringr/blob/main/README.md Install the RegExplain RStudio addin from GitHub using the devtools package. This addin provides an interactive interface for working with regular expressions and stringr functions. ```r # install.packages("devtools") devtools::install_github("gadenbuie/regexplain") ``` -------------------------------- ### String Package Example Execution Error Call Stack Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This snippet shows the call stack leading to an error during the example execution of the stringr package. It highlights the interaction between huxtable and stringr functions, culminating in an error from cli::cli_abort. ```R ... 2. ├─huxtable:::print.huxtable(x) 3. │ └─huxtable (local) meth(x, ...) 4. │ ├─base::cat(to_screen(ht, ...)) 5. │ └─huxtable::to_screen(ht, ...) 6. │ └─huxtable:::generate_table_display(...) 7. │ └─huxtable:::create_character_matrix(...) 8. │ └─huxtable:::character_matrix(...) 9. │ └─huxtable:::prepare_cell_display_data(ht, markdown) 10. │ └─huxtable:::clean_contents(ht, output_type = if (markdown) "markdown" else "screen") 11. │ └─huxtable:::format_numbers_matrix(contents, ht) 12. │ └─base::vapply(...) 13. │ └─huxtable (local) FUN(X[[i]], ...) 14. │ └─base::vapply(...) 15. │ └─huxtable (local) FUN(X[[i]], ...) 16. │ └─huxtable:::format_numbers(cell, nf[[row, col]]) 17. │ └─stringr::str_replace_all(string, number_regex(), format_numeral) 18. │ └─stringr:::str_transform_all(string, pattern, replacement) 19. │ ├─base::withCallingHandlers(...) 20. │ └─huxtable (local) replacement(old_flat) 21. │ └─numeral_formatter(num_fmt)(num) 22. └─base::.handleSimpleError(...) 23. └─stringr (local) h(simpleError(msg, call)) 24. └─cli::cli_abort(...) 25. └─rlang::abort(...) Execution halted ``` -------------------------------- ### HTML mode for viewing alternative matches Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Renders alternative matches using HTML formatting. This example shows how 'd' or 'e' are highlighted when using HTML output. ```R str_view(x, "d|e", html = TRUE)$x$html ``` -------------------------------- ### multinma Installation Failure (Devel) Source: https://github.com/tidyverse/stringr/blob/main/revdep/failures.md This snippet details a compilation error during the installation of the multinma package (devel version). The error indicates a 'Killed signal terminated program cc1plus', suggesting a resource issue during C++ compilation. ```text * installing *source* package ‘multinma’ ... ** this is package ‘multinma’ version ‘0.8.1’ ** package ‘multinma’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ using C++17 g++ -std=gnu++17 -I"/opt/R/4.5.1/lib/R/include" -DNDEBUG -I"../inst/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -DUSE_STANC3 -D_HAS_AUTO_PTR_ETC=0 -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I'/usr/local/lib/R/site-library/rstan/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I/usr/local/include -I'/usr/local/lib/R/site-library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o ... /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:22:0: required from ‘double stan::mcmc::dense_e_metric::T(stan::mcmc::dense_e_point&) [with Model = model_survival_param_namespace::model_survival_param; BaseRNG = boost::random::additive_combine_engine, boost::random::linear_congruential_engine >]’ /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0: required from here /usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:654:74: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type’ {aka ‘__m128d’} [-Wignored-attributes] 654 | return internal::first_aligned::alignment),Derived>(m); | ^~ g++: fatal error: Killed signal terminated program cc1plus compilation terminated. make: *** [/opt/R/4.5.1/lib/R/etc/Makeconf:209: stanExports_survival_param.o] Error 1 ERROR: compilation failed for package ‘multinma’ * removing ‘/tmp/workdir/multinma/new/multinma.Rcheck/multinma’ ``` -------------------------------- ### String Location with Regular Expressions Source: https://github.com/tidyverse/stringr/blob/main/README.md Locates the start and end positions of the first vowel match in each string. The `str_locate()` function returns a matrix of start and end indices. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_locate(x, "[aeiou]") #> start end #> [1,] NA NA #> [2,] 2 2 #> [3,] 3 3 #> [4,] 1 1 #> [5,] 2 2 #> [6,] 1 1 ``` -------------------------------- ### Compiling C++ code with Rcpp and Eigen Source: https://github.com/tidyverse/stringr/blob/main/revdep/failures.md This snippet shows a C++ compilation process using g++ with Rcpp and Eigen libraries, often encountered during R package installation. It highlights potential compilation errors and warnings. ```bash * installing *source* package ‘multinma’ ... ** this is package ‘multinma’ version ‘0.8.1’ ** package ‘multinma’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ using C++17 g++ -std=gnu++17 -I"/opt/R/4.5.1/lib/R/include" -DNDEBUG -I"../inst/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -DUSE_STANC3 -D_HAS_AUTO_PTR_ETC=0 -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I'/usr/local/lib/R/site-library/rstan/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I/usr/local/include -I'/usr/local/lib/R/site-library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o ... /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:22:0: required from ‘double stan::mcmc::dense_e_metric::T(stan::mcmc::dense_e_point&) [with Model = model_survival_param_namespace::model_survival_param; BaseRNG = boost::random::additive_combine_engine, boost::random::linear_congruential_engine >]’ /usr/local/lib/R/site-library/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0: required from here /usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:654:74: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type’ {aka ‘__m128d’} [-Wignored-attributes] 654 | return internal::first_aligned::alignment),Derived>(m); | ^~~~~~~~~ g++: fatal error: Killed signal terminated program cc1plus compilation terminated. make: *** [/opt/R/4.5.1/lib/R/etc/Makeconf:209: stanExports_survival_param.o] Error 1 ERROR: compilation failed for package ‘multinma’ * removing ‘/tmp/workdir/multinma/old/multinma.Rcheck/multinma’ ``` -------------------------------- ### Error for non-character pattern type Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/modifiers.md Provides an example of the error message when the pattern argument is not a character vector. ```R type(1:3) ``` -------------------------------- ### str_trunc with width shorter than ellipsis Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/trunc.md When the specified width is shorter than the ellipsis, str_trunc throws an error. This example shows the default ellipsis length. ```r str_trunc("foobar", 2) ``` -------------------------------- ### str_trunc with custom ellipsis shorter than width Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/trunc.md This example demonstrates an error condition where the specified width is shorter than a custom ellipsis. Ensure width is at least as long as the ellipsis. ```r str_trunc("foobar", 3, ellipsis = "....") ``` -------------------------------- ### Empty Pattern Error in str_starts Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Demonstrates that str_starts throws an error when the pattern is an empty string. ```R str_starts("x", "") ``` -------------------------------- ### String Padding and Concatenation with stringr Source: https://github.com/tidyverse/stringr/blob/main/README.md Demonstrates string padding and concatenation using the stringr package with the pipe operator. The first argument is always the vector of strings to modify, ensuring consistency. ```r letters %>% .[1:10] %>% str_pad(3, "right") %>% str_c(letters[2:11]) ``` -------------------------------- ### Basic stringr Functions Source: https://github.com/tidyverse/stringr/blob/main/README.md Demonstrates fundamental stringr functions for length, concatenation, and substring extraction. These functions operate on vectors of strings. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_length(x) #> [1] 3 5 5 5 4 9 str_c(x, collapse = ", ") #> [1] "why, video, cross, extra, deal, authority" str_sub(x, 1, 2) #> [1] "wh" "vi" "cr" "ex" "de" "au" ``` -------------------------------- ### str_flatten with single string collapse Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/flatten.md Demonstrates the correct usage of str_flatten where the 'collapse' argument is a single string. ```r str_flatten("A", c("a", "b")) ``` -------------------------------- ### Empty Pattern Error in str_detect Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Demonstrates that str_detect throws an error when the pattern is an empty string. ```R str_detect("x", "") ``` -------------------------------- ### str_c() vectorised arguments error (collapse) Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/c.md Illustrates an error when the 'collapse' argument in str_c() is a vector instead of a single string or NULL. ```r str_c(letters, collapse = c("a", "b")) ``` -------------------------------- ### View a vector of strings Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Displays a vector of strings with truncated output. Useful for quickly inspecting the beginning of a large string vector. ```R str_view(words) ``` -------------------------------- ### Deprecated str_view_all usage Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Shows the usage of the deprecated `str_view_all()` function, which has been replaced by `str_view()`. ```R str_view_all("abc", "a|b") ``` -------------------------------- ### Tidyverse Recycling Error in str_starts Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Illustrates tidyverse recycling rules where str_starts fails if the string and pattern sizes cannot be recycled. ```R str_starts(1:2, 1:3) ``` -------------------------------- ### str_match with fixed pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/match.md Demonstrates that `str_match` fails when a fixed pattern is provided instead of a regular expression. ```r str_match(phones, fixed("3")) ``` -------------------------------- ### str_subset with boundary pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/subset.md Shows that str_subset does not permit the use of boundary() as a pattern. ```r str_subset(c("a", "b c"), boundary()) ``` -------------------------------- ### Empty or boundary patterns are invalid Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/replace.md The pattern argument in str_replace and str_replace_all cannot be an empty string or a boundary. This applies to both single and all replacements. ```R str_replace("x", "", "") ``` ```R str_replace("x", boundary("word"), "") ``` ```R str_replace_all("x", "", "") ``` ```R str_replace_all("x", boundary("word"), "") ``` -------------------------------- ### View whitespace characters Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Visualizes whitespace characters in strings, including non-breaking spaces and newlines, which are not always obvious. ```R str_view(x) ``` -------------------------------- ### View whitespace characters using escapes Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Visualizes whitespace characters by explicitly using escape sequences. This provides a clear representation of characters like newline and tab. ```R # or can instead use escapes str_view(x, use_escapes = TRUE) ``` -------------------------------- ### HTML mode for viewing matches Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Renders string matches using HTML formatting, making it easier to visualize patterns within the string context. This is useful for web-based outputs. ```R str_view(x, "[aeiou]", html = TRUE)$x$html ``` -------------------------------- ### Deprecated ignore_case in str_like Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Demonstrates the deprecated `ignore_case` argument in `str_like`, which is still respected but issues a warning and is always case-sensitive. ```R out <- str_like("abc", "AB%", ignore_case = TRUE) ``` -------------------------------- ### Test failures in zipangu due to stringr::str_replace_all Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This test failure indicates an issue with `stringr::str_replace_all` when a replacement function fails because the condition it evaluates has a length greater than 1. The replacement function must be able to handle conditions of any length. ```R stringr::str_replace_all(eqn, pattern = pattern, replacement = reformat_scientific) ``` -------------------------------- ### R DESCRIPTION Note: Modern Syntax Dependency Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This note from the DESCRIPTION file indicates that the package uses R 4.1.0 features like the pipe operator `|>` or shorthand `\(...)`, making it dependent on R version 4.1.0 or later. Ensure the R environment meets this version requirement. ```R Missing dependency on R >= 4.1.0 because package code uses the pipe |> or function shorthand \(...) syntax added in R 4.1.0. File(s) using such syntax: ‘convert-jyear-legacy.R’ ``` -------------------------------- ### View all matches of a pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Highlights all occurrences of a specified pattern within strings. This is useful for visualizing where a pattern appears multiple times. ```R str_view(x, "[aeiou]") ``` -------------------------------- ### str_subset with empty string pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/subset.md Illustrates that str_subset does not allow an empty string as a pattern. ```r str_subset(c("a", "b c"), "") ``` -------------------------------- ### DSMolgenisArmadillo Package Check Status (Devel) Source: https://github.com/tidyverse/stringr/blob/main/revdep/failures.md This snippet shows the output of a package check for the DSMolgenisArmadillo package in its development version. It indicates that all checks passed successfully. ```text * using log directory ‘/tmp/workdir/DSMolgenisArmadillo/new/DSMolgenisArmadillo.Rcheck’ * using R version 4.5.1 (2025-06-13) * using platform: x86_64-pc-linux-gnu * R was compiled by gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 GNU Fortran (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 * running under: Ubuntu 24.04.3 LTS * using session charset: UTF-8 * using option ‘--no-manual’ * checking for file ‘DSMolgenisArmadillo/DESCRIPTION’ ... OK ... * checking files in ‘vignettes’ ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... OK Running ‘testthat.R’ * checking for unstated dependencies in vignettes ... OK * checking package vignettes ... OK * checking re-building of vignette outputs ... OK * DONE Status: OK ``` -------------------------------- ### View patterns across lines Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Demonstrates matching patterns that span across newline characters. This is useful for processing multi-line text. ```R str_view("a\nb\nbbb\nc", "(b|\n)+") ``` -------------------------------- ### View string matches with indices Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Highlights specific patterns within strings and displays the original indices of the matches. The `match = TRUE` argument is used to show the matched parts. ```R str_view(letters, "a|z", match = TRUE) ``` -------------------------------- ### Empty Pattern Error in str_ends Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Demonstrates that str_ends throws an error when the pattern is an empty string. ```R str_ends("x", "") ``` -------------------------------- ### Vector Recycling Error in str_equal Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/equal.md Demonstrates the error that occurs when using `str_equal` with vectors of incompatible sizes that cannot be recycled. ```R str_equal(letters[1:3], c("a", "b")) ``` -------------------------------- ### str_match_all with coll pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/match.md Illustrates that `str_match_all` fails when a coll pattern is provided instead of a regular expression. ```r str_match_all(phones, coll("9")) ``` -------------------------------- ### str_split() input validation: string and pattern size mismatch Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/split.md Demonstrates an error when the 'string' and 'pattern' arguments have incompatible sizes for recycling in str_split(). ```R str_split(letters[1:3], letters[1:2]) ``` -------------------------------- ### str_interp Fails with Nested Placeholders Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/interp.md Demonstrates that str_interp encounters an error when attempting to interpolate nested placeholders. ```R str_interp("${${msg}}") ``` ```R str_interp("$[.2f]${${msg}}") ``` -------------------------------- ### Error in salt_replace with stringr::str_replace_all Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This error occurs when a replacement function used with `stringr::str_replace_all` does not return a vector of the same length as the input string. Ensure the replacement function is designed to handle the input appropriately. ```R x <- c("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "Nunc finibus tortor a elit eleifend interdum.", "Maecenas aliquam augue sit amet ultricies placerat.") salt_replace(x, replacement_shaker$capitalization, p = 0.5, rep_p = 0.2) ``` -------------------------------- ### str_c() vectorised arguments error (sep) Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/c.md Shows an error when the 'sep' argument in str_c() is a vector instead of a single string. ```r str_c(letters, sep = c("a", "b")) ``` -------------------------------- ### DSMolgenisArmadillo Package Check Status (CRAN) Source: https://github.com/tidyverse/stringr/blob/main/revdep/failures.md This snippet shows the output of a package check for the DSMolgenisArmadillo package from CRAN. It indicates that all checks passed successfully. ```text * using log directory ‘/tmp/workdir/DSMolgenisArmadillo/old/DSMolgenisArmadillo.Rcheck’ * using R version 4.5.1 (2025-06-13) * using platform: x86_64-pc-linux-gnu * R was compiled by gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 GNU Fortran (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 * running under: Ubuntu 24.04.3 LTS * using session charset: UTF-8 * using option ‘--no-manual’ * checking for file ‘DSMolgenisArmadillo/DESCRIPTION’ ... OK ... * checking files in ‘vignettes’ ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... OK Running ‘testthat.R’ * checking for unstated dependencies in vignettes ... OK * checking package vignettes ... OK * checking re-building of vignette outputs ... OK * DONE Status: OK ``` -------------------------------- ### str_like Pattern Type Error Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Shows that str_like requires a plain string pattern and errors if a stringr modifier (like regex) is used. ```R str_like("abc", regex("x")) ``` -------------------------------- ### Coercing fixed pattern to character Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/modifiers.md Illustrates the warning produced when a fixed pattern is coerced to a plain character vector. ```R . <- fixed(x) ``` -------------------------------- ### String Manipulation in Test Failures Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This snippet shows a series of `stringr::str_replace_all` calls within a test suite that failed. The errors suggest issues with pattern matching and replacement logic, potentially related to how special characters or whitespace are handled. ```R stringr::str_replace_all(., "([^\\]?)\\\\s", "\\1\\@SPACE2{}") ``` ```R stringr::str_replace_all(., "([^\\]?)\\\\;", "\\1\\@SPACE2{}") ``` ```R stringr::str_replace_all(., "([^\\]?)\\\\,“, "\\1\\@SPACE1{}") ``` ```R stringr::str_replace_all(...) ``` -------------------------------- ### str_match_all with coll pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/match.md Demonstrates that `str_match_all` cannot use other modifiers like `coll` and requires a regular expression. ```r str_match_all("x", coll("y")) ``` -------------------------------- ### Dependency note for salty package Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This note indicates that the 'lifecycle' and 'patchwork' packages are listed in the Imports field of the salty package but are not explicitly imported in the R code, suggesting they might not be used. ```R Namespaces in Imports field not imported from: ‘lifecycle’ ‘patchwork’ All declared Imports should be used. ``` -------------------------------- ### String Package Test Validation Failures Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This snippet lists the output files that failed validation during the test phase for the stringr package. It indicates that test failures occurred across various output formats and platforms. ```text ... • x86_64-w64-mingw32/x64/validate-outputs/dimensions.rtf • x86_64-w64-mingw32/x64/validate-outputs/dimensions.tex • x86_64-w64-mingw32/x64/validate-outputs/dimensions.txt • x86_64-w64-mingw32/x64/validate-outputs/table_caption_tests.html • x86_64-w64-mingw32/x64/validate-outputs/table_caption_tests.rtf • x86_64-w64-mingw32/x64/validate-outputs/table_caption_tests.tex • x86_64-w64-mingw32/x64/validate-outputs/table_caption_tests.txt • x86_64-w64-mingw32/x64/validate-outputs/table_width_tests.html • x86_64-w64-mingw32/x64/validate-outputs/table_width_tests.rtf • x86_64-w64-mingw32/x64/validate-outputs/table_width_tests.tex • x86_64-w64-mingw32/x64/validate-outputs/table_width_tests.txt • x86_64-w64-mingw32/x64/validate-outputs/text_alignment.html • x86_64-w64-mingw32/x64/validate-outputs/text_alignment.rtf • x86_64-w64-mingw32/x64/validate-outputs/text_alignment.tex • x86_64-w64-mingw32/x64/validate-outputs/text_alignment.txt • x86_64-w64-mingw32/x64/validate-outputs/text_effects.html • x86_64-w64-mingw32/x64/validate-outputs/text_effects.rtf • x86_64-w64-mingw32/x64/validate-outputs/text_effects.tex • x86_64-w64-mingw32/x64/validate-outputs/text_effects.txt • x86_64-w64-mingw32/x64/validate-outputs/text_properties.html • x86_64-w64-mingw32/x64/validate-outputs/text_properties.rtf • x86_64-w64-mingw32/x64/validate-outputs/text_properties.tex • x86_64-w64-mingw32/x64/validate-outputs/text_properties.txt Error: Test failures Execution halted ``` -------------------------------- ### str_c() with tidyverse recycling rules error Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/c.md Demonstrates an error when attempting to use str_c() with arguments that violate tidyverse recycling rules. ```r str_c(c("x", "y"), character()) ``` -------------------------------- ### Multiple Pattern/Replacement Pairs in str_replace_all Source: https://github.com/tidyverse/stringr/blob/main/NEWS.md Use a named vector to apply multiple pattern-replacement pairs to a string vector. This is a convenient syntax for complex replacements. ```R input <- c("abc", "def") str_replace_all(input, c("[ad]" = "!", "[cf]" = "?")) ``` -------------------------------- ### Display message for empty vectors Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Shows a message when an empty character vector is provided to `str_view()`, indicating that no strings were supplied for viewing. ```R str_view(character()) ``` -------------------------------- ### HTML mode for viewing whitespace with escapes Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Displays whitespace characters using HTML formatting and escape sequences, providing a clear and structured HTML representation of special characters. ```R str_view(x, html = TRUE, use_escapes = TRUE)$x$html ``` -------------------------------- ### str_dup with numeric separator Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/dup.md Demonstrates the error when a numeric value is provided for the 'sep' argument in str_dup(). The 'sep' argument must be a single string or NULL. ```r str_dup("a", 3, sep = 1) ``` -------------------------------- ### Coercing regex pattern to character Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/modifiers.md Demonstrates the warning generated when a regex pattern is coerced to a plain character vector. ```R . <- regex(x) ``` -------------------------------- ### Replacement function must handle vectorization Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/replace.md When using a replacement function with str_replace_all, it must be able to handle vectors of any length. If the function fails for vectors longer than one element, an error will occur. ```R str_replace_all(x, "a|c", ~ if (length(x) > 1) stop("Bad")) ``` -------------------------------- ### str_sub<- vectorization error Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/sub.md Illustrates an error when the length of the string vector does not match the length of the replacement value vector in str_sub<-. ```r str_sub(x, 1:2, 1:2) <- 1:3 ``` -------------------------------- ### str_flatten error with vector collapse Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/flatten.md Illustrates the error condition when the 'collapse' argument provided to str_flatten is a character vector instead of a single string. ```r Error in `str_flatten()`: ! `collapse` must be a single string, not a character vector. ``` -------------------------------- ### str_ilike Pattern Type Error Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Shows that str_ilike requires a plain string pattern and errors if a stringr modifier (like regex) is used. ```R str_ilike("abc", regex("x")) ``` -------------------------------- ### str_split() input validation: n value Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/split.md Illustrates an error when 'n' is set to 0, which is not a valid number of splits for str_split(). ```R str_split("x", "x", n = 0) ``` -------------------------------- ### String Splitting with Delimiters Source: https://github.com/tidyverse/stringr/blob/main/README.md Splits strings into pieces based on a comma delimiter. The `str_split()` function returns a list of character vectors. ```r str_split(c("a,b", "c,d,e"), ",") #> [[1]] #> [1] "a" "b" #> #> [[2]] #> [1] "c" "d" "e" ``` -------------------------------- ### str_split() input validation: pattern type Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/split.md Shows an error when the 'pattern' argument is not a character vector in str_split(). ```R str_split("x", 1) ``` -------------------------------- ### View multiple matches with OR operator Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/view.md Highlights occurrences of either of two specified characters or patterns within strings. This demonstrates viewing overlapping or alternative matches. ```R str_view(x, "d|e") ``` -------------------------------- ### String Detection with Regular Expressions Source: https://github.com/tidyverse/stringr/blob/main/README.md Uses a regular expression to detect the presence of vowels within strings. The `str_detect()` function returns a logical vector indicating matches. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_detect(x, "[aeiou]") #> [1] FALSE TRUE TRUE TRUE TRUE TRUE ``` -------------------------------- ### String Replacement Function Error Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This error occurs when the replacement function in `stringr::str_replace_all` does not return a character vector as expected. Ensure the replacement function produces character output. ```R stringr::str_replace_all(mod$THETA, "\d+\.\d+", function(x) round(as.numeric(x), digits = 3)) ``` -------------------------------- ### Tidyverse Recycling Error in str_like Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Illustrates tidyverse recycling rules where str_like fails if the string and pattern sizes cannot be recycled. ```R str_like(1:2, c("a", "b", "c")) ``` -------------------------------- ### str_dup with character vector separator Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/dup.md Illustrates the error when a character vector is provided for the 'sep' argument in str_dup(). The 'sep' argument must be a single string or NULL. ```r str_dup("a", 3, sep = c("-", ";")) ``` -------------------------------- ### Incorrect Encoding Argument in str_conv Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/conv.md Demonstrates an error when the `encoding` argument in `str_conv()` is provided as a character vector instead of a single string. ```R str_conv("A", c("ISO-8859-1", "ISO-8859-2")) ``` -------------------------------- ### str_sub vectorization error Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/sub.md Demonstrates an error when the length of the string vector does not match the length of the end position vector in str_sub. ```r str_sub(x, 1:2, 1:3) ``` -------------------------------- ### String Replacement with Regular Expressions Source: https://github.com/tidyverse/stringr/blob/main/README.md Replaces the first occurrence of a vowel in each string with a '?'. The `str_replace()` function returns the modified strings. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_replace(x, "[aeiou]", "?") #> [1] "why" "v?deo" "cr?ss" "?xtra" "d?al" "?uthority" ``` -------------------------------- ### Coercing coll pattern to character Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/modifiers.md Shows the warning when a coll pattern is coerced to a plain character vector. ```R . <- coll(x) ``` -------------------------------- ### Error in stringr::str_replace_all during phenofit check Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This error occurs within the phenofit package when using stringr::str_replace_all, indicating a potential issue with string manipulation patterns or replacements. ```R 11. │ └─xc %<>% str_replace_midzero() 12. ├─phenofit:::str_replace_midzero(.) 13. │ └─str_replace_all(x, "\\++0\\++", . %>% replace("+")) %>% 14. ├─stringr::str_replace_all(., "-+0-+", . %>% replace("-")) 15. │ └─stringr:::str_transform_all(string, pattern, replacement) ``` -------------------------------- ### str_interp Wraps Parsing Errors Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/interp.md Illustrates how str_interp wraps and reports underlying parsing errors when the interpolation expression is invalid. ```R str_interp("This is a ${1 +}") ``` -------------------------------- ### str_split_i() input validation: i value (zero) Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/split.md Shows an error when 'i' is set to 0 for str_split_i(), as it must be a positive whole number. ```R str_split_i("x", "x", 0) ``` -------------------------------- ### str_interp Fails with Non-Character Input Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/interp.md Shows that str_interp requires a character vector as input and will error if given other types, such as a numeric literal. ```R str_interp(3L) ``` -------------------------------- ### String Counting with Regular Expressions Source: https://github.com/tidyverse/stringr/blob/main/README.md Counts the occurrences of vowels within each string using a regular expression. The `str_count()` function returns the number of matches. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_count(x, "[aeiou]") #> [1] 0 3 1 2 2 4 ``` -------------------------------- ### Replacement must be a string Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/replace.md The replacement argument in str_replace must be a character vector. Providing a number will result in an error. ```R str_replace("x", "x", 1) ``` -------------------------------- ### String Package Dependency Note Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This snippet indicates that certain namespaces listed in the Imports field of the stringr package's R code were not explicitly imported. It suggests that all declared Imports should be utilized. ```R Namespaces in Imports field not imported from: ‘R6’ ‘xml2’ All declared Imports should be used. ``` -------------------------------- ### Backreferences must be within bounds Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/replace.md When using backreferences in str_replace_all, ensure they refer to valid captured groups. Attempting to access an out-of-bounds group will result in an error. ```R str_replace_all("abcde", "(b)(c)(d)", "\4") ``` -------------------------------- ### Error for NA values in character pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/modifiers.md Demonstrates the error when a character vector pattern contains NA values. ```R type(c("a", "b", NA_character_, "c")) ``` -------------------------------- ### str_split_fixed() input validation: n value Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/split.md Highlights an error when 'n' is set to 0 for str_split_fixed(), as it must be greater than 1. ```R str_split_fixed("x", "x", 0) ``` -------------------------------- ### Replacement function must return correct type and length Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/replace.md The replacement function used with str_replace_all must return a character vector. It must also return a vector of the same length as the input. Returning a number or a vector of incorrect length will cause an error. ```R str_replace_all("x", "x", ~1) ``` ```R str_replace_all("x", "x", ~ c("a", "b")) ``` -------------------------------- ### str_match with coll pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/match.md Shows that `str_match` cannot use other modifiers like `coll` and requires a regular expression. ```r str_match("x", coll("y")) ``` -------------------------------- ### Tidyverse Recycling Error in str_detect Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Illustrates tidyverse recycling rules where str_detect fails if the string and pattern sizes cannot be recycled. ```R str_detect(1:2, 1:3) ``` -------------------------------- ### Test failures in psycModel related to model_table Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md These test failures in the psycModel package indicate discrepancies in the output of the model_table function for linear regression models, specifically concerning the names of coefficients. ```R `lm_1_check` (`actual`) not equal to model_summary[[2]] (`expected`). `names(actual)`: "(Intercept)" "Sepal.Length" `names(expected)`: "" "" `lm_2_check` (`actual`) not equal to model_summary[[3]] (`expected`). `names(actual)`: "(Intercept)" "Petal.Length" `names(expected)`: "" "" ``` -------------------------------- ### str_split_i() input validation: i value (non-integer) Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/split.md Demonstrates an error when 'i' is a non-integer value for str_split_i(), as it must be a whole number. ```R str_split_i("x", "x", 0.5) ``` -------------------------------- ### String Matching with Capture Groups Source: https://github.com/tidyverse/stringr/blob/main/README.md Extracts characters surrounding the first vowel using capture groups in a regular expression. The `str_match()` function returns a matrix with captured groups. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") # extract the characters on either side of the vowel str_match(x, "(.)[aeiou](.)") #> [,1] [,2] [,3] #> [1,] NA NA NA #> [2,] "vid" "v" "d" #> [3,] "ros" "r" "s" #> [4,] NA NA NA #> [5,] "dea" "d" "a" #> [6,] "aut" "a" "t" ``` -------------------------------- ### R Test Failure: str_replace with NA pattern Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This R code snippet illustrates a test failure in the stringr package where `str_replace` encountered an NA pattern, leading to an error. This typically occurs when data processing results in unexpected NA values within the patterns used for string replacement. ```R res <- res %>% purrr::list_merge(city = split_pref[2] %>% dplyr::if_else(is_address_block(.), stringr::str_remove(., "((土地区画|街区).+)") %>% stringr::str_remove("土地区画|街区"), .) %>% stringr::str_replace(city_name_regex, replacement = "\1")) } else { res <- res %>% purrr::list_merge(city = split_pref[2] %>% dplyr::if_else(is_address_block(.), stringr::str_remove(., "((土地区画|街区).+)") %>% stringr::str_remove("土地区画|街区"), .) %>% stringr::str_replace(paste0(city_name_regex, "(.+)"), replacement = "\1")) } res <- res %>% purrr::list_merge(street = split_pref[2] %>% stringr::str_remove(res %>% purrr::pluck("city"))) res %>% purrr::map(~dplyr::if_else(.x == "", NA_character_, .x)) }) ``` -------------------------------- ### String Extraction with Regular Expressions Source: https://github.com/tidyverse/stringr/blob/main/README.md Extracts the first vowel found in each string. The `str_extract()` function returns the matched text. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_extract(x, "[aeiou]") #> [1] NA "i" "o" "e" "e" "a" ``` -------------------------------- ### Error for NA pattern Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/modifiers.md Shows the error message when the pattern argument is NA. ```R type(NA) ``` -------------------------------- ### String Replace Pattern Error Source: https://github.com/tidyverse/stringr/blob/main/revdep/problems.md This error indicates that the pattern used in `stringr::str_replace` contains NA values, which is not permitted. Verify that the pattern vector does not include any NA elements before calling the function. ```R stringr::str_replace(rvest::html_text2(home_node), home_role_full, "") ``` -------------------------------- ### Tidyverse Recycling Error in str_ends Source: https://github.com/tidyverse/stringr/blob/main/tests/testthat/_snaps/detect.md Illustrates tidyverse recycling rules where str_ends fails if the string and pattern sizes cannot be recycled. ```R str_ends(1:2, 1:3) ``` -------------------------------- ### String Subset Extraction with Regular Expressions Source: https://github.com/tidyverse/stringr/blob/main/README.md Extracts strings that contain at least one vowel using a regular expression. The `str_subset()` function returns the matching strings. ```r x <- c("why", "video", "cross", "extra", "deal", "authority") str_subset(x, "[aeiou]") #> [1] "video" "cross" "extra" "deal" "authority" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.