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
3
votes
2 answers

Unable to install stringi R package on MacOS M1 Monterey

I have been unable to install the R package stringi on my Macbook Pro (running MacOS Monterey) with the new M1 & arm64 architecture. There are a number of posts on SO describing similar problems, but the error message I'm receiving is something I…
3
votes
2 answers

R - fast way to find all vector elements that contain all search terms

I have the same question answered here R - Find all vector elements that contain all strings / patterns - str_detect grep. But the suggested solution is taking too long. I have 73,360 observations with sentences. I want a TRUE return for matches…
guasi
  • 1,461
  • 3
  • 12
3
votes
5 answers

Conditional string concatenation in same column in R

I am new to R and have a very large irregular column in a data frame like this: x <- data.frame(section = c("BOOK I: Introduction", "Page one: presentation", "Page two: acknowledgments", "MAGAZINE II: Considerations", "Page one: characters", "Page…
3
votes
2 answers

How to loop through mapply in R?

I am trying to concatenate strings using mapply function in R. However, I want one of the strings to be variable in mapply function. I have a snippet of my code…
user86907
  • 817
  • 9
  • 21
3
votes
3 answers

extract text from email and between two dots in R

I have some email address where I am trying to extract the domain from. I found a solution here but it is taking too long. I am trying with the following approach: First remove all the text before the @ sign. gsub("@(.+)$", "\\1", emails) Other -…
user8959427
  • 2,027
  • 9
  • 20
3
votes
1 answer

write.csv() writes a different result from Mac OS than from Windows 10?

Character strings that look completely normal when printed to the RStudio console but appear as strange characters when written to csv and opened with excel. Reproducible example The following generates the object that appears as the string "a…
stevec
  • 41,291
  • 27
  • 223
  • 311
3
votes
3 answers

Generate a unique random string in R using stringi

I have data where each row is a person. I want to make a randomly generated unique ID, so I can identify them in analysis. Here is a sample dataframe df <- data.frame( gender = rep(c("M", "F", "M", "M", "F"), 1000), qtr = sample(c(1:99), 50000,…
Laura
  • 499
  • 5
  • 13
3
votes
5 answers

extracting the second last word between the special characters "/"

I would like to extract the second last string after the '/' symbol. For example, url<- c('https://example.com/names/ani/digitalcod-org','https://example.com/names/bmc/ambulancecod.org' ) df<- data.frame (url) I want to extract the second word…
user3570187
  • 1,743
  • 3
  • 17
  • 34
3
votes
1 answer

Find nonsense words in a text

I have a dataset with answers of user if they know a brand or not. Some of the users just answered nonsense, as you can see in my example. meinstring <- c("----asdada", "no idea", "C&A", "aaaaaaaaaa", "---", "adaosdjasodajsdoad") spamidenfifier…
user7353167
3
votes
1 answer

Appveyor problem - R package stringi can't be installed

Lately the build with Appveyor does not work any more. It fails before actually building the program, because somehow the package stringi can't be installed. Locally everything works fine, but I need a workaround for Appveyor. Has anybody a solution…
Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
3
votes
1 answer

R: split string vector by delimiter and rearrange

I have string vector that needs to be split and rearranged in a matrix in a certain way. I know how to do split/simple rearrange, but lost how my to rearrange how I want: library(stringi) vec = c("b;a;c","a;c","c;b") q = stri_split_fixed(vec, ";",…
Alexey Ferapontov
  • 5,029
  • 4
  • 22
  • 39
3
votes
0 answers

Parsing Unicode string with nulls in R

I am having some trouble parsing a Unicode string a JSON object pulled from an API. As the string has Encoding() like "unknown", i need to parse it for the system to know what its dealing with. The string represents a decoded .png file in UTF-8 that…
Henrik
  • 1,101
  • 9
  • 7
3
votes
2 answers

Removed non-ASCII values and then lowering text is giving error

I have a big data set which I cleaned up and found that one of the fields has value like "My son is turning into a monster \xf0\u009f\u0098\u0092" I am not able to create this simple data as it gives the below mentioned error a <- c('My son is…
Vineet
  • 1,492
  • 4
  • 17
  • 31
3
votes
1 answer

Rstudio how to get stringi package installation to work? All good until dyn.load simply fails

At wit's end after updating to latest: my Ubuntu 16.04LTS update/upgrades, my R version, my Rstudio-server version, my libicu-dev version, verified that anaconda is providing my python but not my R language. What else can help? This stringi…
Geoffrey Anderson
  • 1,534
  • 17
  • 25
3
votes
1 answer

Stringi/stringr pattern behave differently if function is sourced in R

I am using the stringi package for a while now and everything works fine. I recently wanted to put some regex inside a function and store that function in a separate file. The code works just fine if the function is loaded from the script but when…
maRmat
  • 363
  • 1
  • 14