Questions tagged [stringi]

stringi is THE R package for fast, correct, consistent and convenient string/text processing in each locale and any native character encoding. The use of the ICU library gives R users a platform-independent set of functions known to Java, Perl, Python, PHP, and Ruby programmers.

's stringi package provides a platform independent way of manipulating strings. It is built on the library and has a syntax inspired by the package.

Repositories

Other resources

Related tags

298 questions
9
votes
4 answers

Unexpected behaviour with str_replace "NA"

I'm trying to convert a character string to numeric and have encountered some unexpected behaviour with str_replace. Here's a minimum working example: library(stringr) x <- c("0", "NULL", "0") # This works, i.e. 0 NA 0 as.numeric(str_replace(x,…
jkeirstead
  • 2,881
  • 3
  • 23
  • 26
9
votes
2 answers

r ngram extraction with regex

Karl Broman's post: https://kbroman.wordpress.com/2015/06/22/randomized-hobbit-2/ got me playing with regex and ngrams just for fun. I attempted to use regex to extract 2-grams. I know there are parsers to do this but am interested in the regex…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
7
votes
1 answer

R package long time to install - Source or Binary type

Am trying to install a package called stringi using the below command install.packages("stringi") Though it doesn't throw any error message but the installation is not over yet. I see lot of messages in my console screen which keeps running for more…
The Great
  • 7,215
  • 7
  • 40
  • 128
7
votes
3 answers

Get text from href tag after specific class

I am trying to scrape a webpage library(RCurl) webpage <- getURL("https://somewebpage.com") webpage
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
7
votes
2 answers

using captured groups in str_replace / stri_replace - stringi vs stringr

Most stringr functions are just wrappers around corresponding stringi functions. str_replace_all is one of those. Yet my code does not work with stri_replace_all, the corresponding stringi function. I am writing a quick regex to convert (a subset…
asachet
  • 6,620
  • 2
  • 30
  • 74
6
votes
1 answer

R: create a new folder using the given path

I would like to create a new folder(newPack) in the parent folder(pathPos) of a given path(path) using R functions. path <- "/m/home/user/unix/R/3.5/stringi" newPack <- "stringr" pathPos <- stringi::stri_locate_last_fixed(path, '/')[-1] pathNew <-…
Prradep
  • 5,506
  • 5
  • 43
  • 84
6
votes
1 answer

Difference between `paste`, `str_c`, `str_join`, `stri_join`, `stri_c`, `stri_paste`?

What are the differences between all of these functions that seem very similar ?
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
6
votes
2 answers

How to use paste with for-loops?

I am trying to use the function stri_join, from the library stringi in a loop, but I am having difficulties. I would like to obtain "A_1.png", "A_2.png", "A_3.png", "A_4.png", "A_5.png", and so on until "A_200.png". Here is my attempt: x <-…
dede
  • 1,129
  • 5
  • 15
  • 35
6
votes
3 answers

Sequentially replace multiple places matching single pattern in a string with different replacements

Using stringr package, it is easy to perform regex replacement in a vectorized manner. Question: How can I do the following: Replace every word in hello,world??your,make|[]world,hello,pos to different replacements, e.g. increasing…
Kun Ren
  • 4,715
  • 3
  • 35
  • 50
5
votes
3 answers

Replace letters in a template string in R

Given a "template" of a UK postcode, such as "A9 9AA", where "A" is a letter placeholder, and "9" is a number placeholder, I want to generate random postcode strings like "H8 4GB". Letters can be any uppercase letter, and numbers anything from 0 to…
Spacedman
  • 92,590
  • 12
  • 140
  • 224
5
votes
4 answers

stringi install error: configure: error: C compiler cannot create executables

I am trying to install stringi package after a recent update of R to newest version. However, I met this error: * installing *source* package ‘stringi’ ... ** package ‘stringi’ successfully unpacked and MD5 sums checked checking for local…
mt1022
  • 16,834
  • 5
  • 48
  • 71
5
votes
1 answer

R Studio installing stringi fails

I'm trying to invoke knit which tells me that it needs an updated version of rmarkdown which needs the package stringi. When installing stringi I get the following error: > install.packages("stringi") Installing package into…
user47376
  • 2,263
  • 3
  • 21
  • 26
5
votes
0 answers

perl case convention with stringi

I can use the perl argument in gsub to change the case of individual subexpressions. For example if I want to find a lower case i followed by and apostrophe or end of string (redundant here) I could do: gsub("(\\bi(\\b|'))", "\\U\\1", "i am able to…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
5
votes
2 answers

Extract year from string and text data

I need extract start year and end year from a vector with values of these nature. yr<- c("June 2013 – Present (2 years 9 months)", "January 2012 – June 2013 (1 year 6 months)","2006 – Present (10 years)","2002 – 2006 (4 years)") yr June 2013 –…
user3570187
  • 1,743
  • 3
  • 17
  • 34
5
votes
1 answer

(Skip)(Fail) Parse error with stringi

I was reading/learning The Greatest Regex Trick Ever where we say we want something unless...using (*SKIP)(*FAIL). OK so I took it for a spin on the toy example below and it works in base R but has the following error in stringi. Do I need to do…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
1
2
3
19 20