2,615 questions
0
votes
2
answers
114
views
Regex not capturing correct group [duplicate]
I need to capture the third instance of a pattern using regex. My code works using the online R Regex Tester, but not with the stringr::str_extract() function.
What is the reason for this?
string = c(&...
1
vote
1
answer
176
views
Replacing a character if it is preceded by double quote and several digits [duplicate]
Assume the following string:
text <- '125,3,56,"50,38 %",12'
I now want to replace the comma by a dot if the comma is directly preceded by a double quote and up to several digits.
So in ...
0
votes
2
answers
89
views
Extract last numbers from text strings [duplicate]
I have a large dataframe with a column of strings that have either 1 or 2 numbers at the end of the string. I'd like to extract these 1 or 2 numbers and place them in a new column. Here is how I am ...
-2
votes
1
answer
96
views
R: Partial matching values in a vector with partial match in df [duplicate]
I am trying to do some inventory management, I have a list of catalog numbers of materials we need and a list of managed stock onsite. I have a vector of catalog numbers (num) which are accurate to ...
0
votes
0
answers
29
views
Escaping by a inserting a slash before special characters [duplicate]
I have the following list of words/phrases:
vec <- c("Apple (Red)",
"Ginger [Indian]",
"Avocado",
"Cherry: Spring time")
I want to ...
3
votes
4
answers
106
views
Count how often words from a vector occur in a string
I have a string of text and a vector of words:
String: "Auch ein blindes Huhn findet einmal ein Korn."
Vector: "auch", "ein"
I want to check how often each word in the ...
5
votes
4
answers
135
views
Grouping string together and sum it together
I have a very similar problem to solve like this. However, I am not interested in sorting. I am interested in grouping (wrong word perhaps) the same string objects together and sum the value attached ...
1
vote
2
answers
91
views
Spliting 1 column into 2 with str_split() in R [duplicate]
I have this dataframe
# My dataframe
df <- data.frame(
id_do_cliente = c(852, 966, 677, 877, 176, 69, 688, 525, 307, 127),
nome_completo = c(
"John Smith", "Emily Johnson&...
1
vote
2
answers
239
views
How do I change cell text color in flextable based on a string?
In Flextable, I'm trying to change the color of the text in a cell if it detects a "+" (green) or "-" (red). The help guide is really clear on how to do this for numeric data, but ...
0
votes
1
answer
21
views
Matching a string based on specific subparts
Imagine I am given some complicated string
string_complicated = "asfdalksdVARIABLE1/djdj/.VARIABLE2?jjjVARIABLE3yuuu"
which contains the variables VARIABLE1, VARIABLE2, VARIABLE3.
Now ...
2
votes
4
answers
114
views
Lost on how to separate columns
I want to separate a column of my dataset into different columns. However, the problem is that the column of interest is dirty and does not split the I want. This is the column I have.
notified_amount
...
1
vote
0
answers
26
views
How to evaluate elements of a character vector inside a function in R to dynamically create data variables? [duplicate]
I have a dataset similar to this:
library(tibble)
df <- data.frame(
basket = c("A1", "A2", "A3", "A4", "A5", "A6", "A7", &...
3
votes
2
answers
94
views
How to mutate all values except for a vector of selected values with case_when() [closed]
I'm cleaning a list of business names and I'm struggling to selectively convert the cases to title case. I can use the mutate(str_to_title(...)) functions to convert the whole field to title case, and ...
0
votes
2
answers
69
views
command including str_extract_all not returning expected results within mutate()
I have a vector containing strings, each containing an alphanumeric code with integers having values 1-3 (ex. "1RV2GA"). I want to extract the numbers and get their sum. So for "1RV2GA&...
4
votes
4
answers
127
views
Search multiple keywords over a column and create columns for each
I have the following data.
stringstosearch <- c("to", "and", "at", "from", "is", "of")
set.seed(199)
datatxt <- data.frame(id = c(...