All Questions
5,816
questions
3
votes
2
answers
85
views
R: Efficient way to str_replace_all without recursively replacing conflicting substitutions?
Hello,
The problem
First, let me try to illustrate the problem. Assume I want to apply the following cipher to encode the string, "abc".
library(tidyverse)
cipher <- tibble(
byte = c(...
0
votes
2
answers
48
views
Is there a way to obtain a list separated by comma as the output of str_extract_all instead of the default output in R?
I have searched high and low and nobody seems to have asked that exact question, so I'm at loss.
I have a data frame with a couple columns. One of this column contains various sentences that don't ...
1
vote
5
answers
85
views
String Manipulation based on Char Length in a dataframe
I wanted to do some string manipulation based on Char length condition.
I have this table, let's called it sample table.
RiskCode
A01
A02.999
I want to transform the RiskCode column in sample ...
0
votes
4
answers
71
views
Substring replacement in data frame, based on a look-up table [closed]
As input, I've got a large data frame in R with lists of strings of different lengths, referring to certain codes - like this:
glt.code glt.phylogeny
1 adha1238 adha1238 ...
0
votes
2
answers
34
views
make groups by a dictionary in R
I have the task of identifying the group to which a sentence belongs according to the use of specific words, for example identifying which color has been used to describe an animal. I have a ...
1
vote
3
answers
51
views
Cell value breakdown and string split with uneven length
I need to breakdown the string values contained in a column. Some cells do not need any split at all. Others might required one, two, or more.
I would also like the split values to be stored in ...
1
vote
0
answers
48
views
Convert ordinal word string to ordinal number string? [duplicate]
Suppose I have a vector containing ordinal number words as strings in R:
ordinal_words<-c("FIRST COMPANY", "BAKERY FIFTH AVENUE", "WEST FORTIETH WAY")
I would like ...
1
vote
3
answers
54
views
Understanding why grepl doesn't appear to be correctly identifying words
I'm trying to count occurrences of a word in a document (as part of some research I'm doing into how politicians use language). I don't understand why the value I'm getting back in R is not the same ...
1
vote
1
answer
52
views
Expand the string in R
I have a string
a <- c("C1", "C2", "C3)
and want to expand each element with ":A1" so that the whole sequence will be
"C1:A1" "C2:A1" "...
6
votes
7
answers
289
views
Count empty strings?
In R, suppose I have a vector like:
vector<-c("Red", " ", "", "5", "")
I want to count how many elements of this vector are just empty strings ...
1
vote
2
answers
40
views
How can I split a string on whitespaces or quotes if they're present
Context: I have a list of keywords that sometimes consist of one word (e.g. poisson, normal, ...) and sometimes consist of two words, which are then within single quotes ('Two-way ANOVA', 'Generalized ...
1
vote
1
answer
24
views
Changing isolated words in R?
In R, I have a character vector like:
vector<-c("BAKING CO", "NEW COBALT", "CO INC")
I would like to convert the word "CO" to "COMPANY", but only ...
-1
votes
0
answers
21
views
regex: Can't catch first occurence of character group [duplicate]
I have column names like this: var1, var2, var3, .... var99. but sometimes there are wrong entries between var and the number, something like var dfdsf 22. I want to extract only the relevant part, ...
1
vote
2
answers
75
views
Replace ordinal numbers in R?
In R, suppose I have a string vector composed of words:
string1<-c("1ST COMPANY", "21ST LIBRARY")
However, within these strings, I want to convert ordinal number words like &...
0
votes
3
answers
34
views
Add custom text in string based on values specified in text vector in R
Let's say I have a vector of string values that looks something like:
vec_vals<-c("value1", "value2", "value3")
and a text string which at certain points may contain ...