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
1
vote
1 answer

How to do a find/replace with a regular expession in stringr

Given a string like 'run- ning' I would like to replace 'n- n' by 'nn' in order to obtain 'running'. Using the stringr package I tried this: str_replace_all(s, "[:alpha:]\\-([ ])+[:alpha:]", "[:alpha:][:alpha:]") but it seems not to work that way.…
WJH
  • 539
  • 5
  • 14
1
vote
1 answer

installing stringr, stringi "Error: package or namespace load failed for ‘stringi’ in dyn.load(file, DLLpath = DLLpath, ...)" and shared object issue

I am using Fedora 32, compiled from source the latest R 4.0.2 (the problem persists even under another clean install of 3.6.3). I got this error > install.packages("stringi") Installing package into…
Andrés Parada
  • 319
  • 7
  • 21
1
vote
3 answers

R split a character string into multiple columns when have different string lengths, dplyr

I have animal tracking data where each animal was encountered over time and the sex was recorded at each encounter. There are three types of encounters (type1, type2, and type3). Each row represents an animal and each encounter is classified as M…
sbliss
  • 87
  • 2
1
vote
3 answers

Replace common expressions in a data frame

I have a data frame made of texts taken from Wikipedia. An example would be: dput(text3) structure(list(texts = c("Apollo 13 was the seventh crewed mission in the Apollo space program and the third meant to land on the Moon. The craft was launched…
RodLL
  • 110
  • 8
1
vote
0 answers

Cannot install packages because "stringi cannot be built. Check your complier flags"

No matter what packages I try to install, it does not work. Tidyverse, ggplot2, dplyr. Nothing works. After looking through the long lists of error messages, I got to the root of the problem. *** stringi cannot be built. Check your compiler flags…
E Tam
  • 148
  • 6
1
vote
0 answers

stri_rand_shuffle internal error depending on how many elements passed at once

What is the reason for this behavior? x = c(uryat = "uryatg", helyabinsk = "helyabinskj", hukot = "hukoto", huvash = "huvashx", almyk = "almykf", aluga = "alugax", arelia = "areliay", emerovo = "emerovor", hakass = "hakassq",…
Rafael
  • 3,096
  • 1
  • 23
  • 61
1
vote
2 answers

R - How to make a stringi str_extract pattern parametric in a loop

I have strings that are segmented by forward-slashes, I am trying to generate this using a loop so I need to parametrize the regex so that I can use it inside a loop. I have 7 levels: I want to extract the followings using the regex and…
Ibo
  • 4,081
  • 6
  • 45
  • 65
1
vote
3 answers

For every time id1 is within the string in id3, put the id2 part in the new column

I would like to generate one additional column to this data frame with some additional information: every time id1 is within the string in id3, replace this portion with its counterpart in id2: library(tidyverse) df1 <- tibble( id1…
Marie-Eve
  • 565
  • 4
  • 15
1
vote
1 answer

How do you split the following vector of strings based on a delimiter that occurs after a certain character pattern in R?

Here is an example of the vector: strings<- (c("SPG_L_SPG_R", "SAS_SPG_R_SFG_L", "s_cere_R_SPG_L" )) I need the split strings to be "SPG_L", "SPG_R","SAS_SPG_R", "SFG_L", "s_cere_R", "SPG_L" I want to split the string at "_" that occurs after…
nagpal826
  • 67
  • 5
1
vote
2 answers

Obtaining string after other string

I have a data.frame similar to the displayed below. How can I take the 2 and 1 value previous to string hours and hour and to sum? Input test <- data.frame(value = c('Stick 1 whole clove into center of each diamond. Roast ham 2 hours. Reduce oven…
Wagner Jorge
  • 430
  • 3
  • 15
1
vote
1 answer

(R) - Check if substring is contained in larger string and change value

I am attempting to check a column in my dataset that is all character values with values like: "1","2","12","NAME1","NAME2",... I am attempting to pick out the values that have non-numeric names and change them to 99. This is what I have attempted…
user2813606
  • 797
  • 2
  • 13
  • 37
1
vote
3 answers

Replace multiple characters, by index, in a string quickly

I'm trying to quickly replace multiple characters in a string with another character such as * For example, I have a string such as: string = "abcdefghij" I also have a vector of indexes that indicate where I would like to replace letters in the…
InfiniteFlash
  • 1,038
  • 1
  • 10
  • 22
1
vote
1 answer

How can I make these visually identical strings computationally equal?

Context: I'm looking to join two tibbles based on a character vector, but something has happened between write.csv() and read.csv() that has made them non-equivalent. In the reprex below, str_cmp() returns 0 (a 'match'), but in my actual project it…
Captain Hat
  • 2,444
  • 1
  • 14
  • 31
1
vote
1 answer

stringi functions within dplyr

I wanted to modify the method in another post (Reading in Unicode Emoji correctly into R), to check if a unicode string corresponds to an emoji... but I obviously haven't quite grasped how to use stringi correctly. The first section of code is a…
user1420372
  • 2,077
  • 3
  • 25
  • 42
1
vote
7 answers

How to extract number between two strings?

I have a vector like below id < c("1250.3000488281_-57.882898769379_OilA") I need to extract the number after the _ i.e -57.882898769379. I tried something like this library(magrittr) id_play %>% …