Skip to main content

All Questions

Tagged with
0 votes
1 answer
33 views

Remove string from column across group of rows in another column

I would like to remove a string from one column across a group of rows in another column. In the below reprex, I would like to remove the string in snippet from the string in text in any row in the ...
maia-sh's user avatar
  • 557
4 votes
3 answers
81 views

How to extract birth and death year from string in R?

I have the first paragraph of Wikipedia articles from the wikifacts package (only for people). I like to extract birth year and year of death. library(wikifacts) library(tidyverse) politicians <- ...
Marco's user avatar
  • 2,727
2 votes
1 answer
64 views

Extract *all* possible patterns in a variable

I have a large variable containing strings (words). I need to extract all substrings that contain any of the patters listed in a separate vector. library(tidyverse) df <- data.frame(Word = c("...
RobertP.'s user avatar
  • 285
0 votes
3 answers
52 views

Flawed logic with RegEx and numeric ranges

I'm trying to create a new variable called 'group' in a dataset called 'data'. The variable 'group' should take the value "A" or "B" depending on how another variable in the ...
Xavier Villà Aguilar's user avatar
3 votes
3 answers
73 views

Removing second or third occurrence of a pattern from a string

I want to remove a specific letter from a string. removing the first A works with str_remove(). But now I want to remove only the second and only the third A. Is there a function for that or any ...
Lina's user avatar
  • 31
1 vote
2 answers
128 views

tidyverse/dplyr solution for str_detect case/mutate

I have seen snippets of this floating around but sadly no full answers as of yet so thought I would ask. I'm working on a function to assign a value based off the presence or absence of some key words ...
TDeramus's user avatar
  • 160
0 votes
2 answers
62 views

Undo the str_wrap()

I would like to un-wrap the wrapped text in r. However, it is not successful after as.character(). Here is a toy code: t<-c("The adds fundamental principle”, The discriminatory ") ...
William Wong's user avatar
3 votes
3 answers
100 views

Is there a way to replace a group of strings with another group if strings via dplyr and stringr

I have reproduced a simple version of my problem. I essentially want to replace the English words in the statement column with the Spanish equivalent, for all statements. library(tidyverse) english &...
Dontai Lewis's user avatar
5 votes
5 answers
158 views

Order a number by increased digits [duplicate]

Apologize if it has been already asked but I'm trying to "change" the order of digits of numbers in a vector. Let's take as an example this vector: vector = c("5213456","...
WalliYo_'s user avatar
  • 385
1 vote
4 answers
66 views

Filter dataframe by string matching by row

Suppose the following dataframe : data.frame(Var1=c("1 2 3","1 6","2 5 9","1 5 3"),Var2 = c("1 2","1 6 0 5","3 7",&...
WalliYo_'s user avatar
  • 385
0 votes
1 answer
69 views

Dynamic mutate case_when according to string matching

I have a vector which stores all possible merging combinations for a qualitative variable. The vector has the following structure : Config = c("4 With 1 + 6 With 2 + 8 With 3","4 With ...
WalliYo_'s user avatar
  • 385
0 votes
1 answer
47 views

Remove part of string in one column based on overlap with another column (context-dependent)

I have the following data where everything is a string: Column A Column B "Do you like banana splits?" "Do you like banana splits? Yes, I do" "I am John" "I am ...
user22571454's user avatar
0 votes
2 answers
57 views

Recombine characters strings and separate initals with a period using R and Regex

I have a list of authors that are all slightly formatted differently. My goal is to extract the different components of every character string. The different components are: initials (usually all ...
Nick's user avatar
  • 155
2 votes
2 answers
33 views

Remove part of a string from a data.frame column

I'm working with a data.frame that contains one character column. I would like to make changes to some of the rows. For instance, on row 54 I would like to remove ", Energy Transport System ...
Filipe Dias's user avatar
1 vote
1 answer
93 views

How to wrap values of a row into new line at specific character in R

I have a sample dataframe with values: data <- structure(list(A = c("Date)", "Values"), B = c("2023-04-03", "Heat Capacity\nSpecific Heat Capacity\nHeat Index&...
Golem's user avatar
  • 134

15 30 50 per page
1
2 3 4 5
17