All Questions
5,880 questions
3
votes
6
answers
155
views
Apply string split into list
I have the following string:
exm<-"c(1,2,3),c(4,5),c(7,8,9),c(10,11)"
I need to convert this into a list with vectors with 3 or 2 elements (according with the string), so far by now my ...
4
votes
5
answers
103
views
R: replace multiple occurrences of regex-matched strings in dataframe fields by looking them up in another dataframe
I have two dataframes:
df lookup:
oldId <- c(123, 456, 567, 789)
newId <- c(1, 2, 3, 4)
lookup <- data.frame(oldId, newId)
df data:
descr <- c("description with no match",
+ &...
5
votes
1
answer
64
views
Split version numbers to find latest version [duplicate]
I am working with version numbers and need to pull the latest version. In this case it is 1.11.3. I have a working solution, but I am hoping there is a more elegant R way of doing this. Here is my ...
12
votes
9
answers
1k
views
How do I create a new vector from a previous vector with elements in a specific order in R?
I have a vector in R
vec <- c("x", "y", "z")
I want to generate a new vector with elements, in order, based off the elements of vec. I want the result to be:
"x&...
1
vote
1
answer
40
views
Extracting an outcome or string from a 'frtest' object (FRAIR package in R)
I'm trying to run a simulation experiment using simulated functional response data. My goal is to use frair_test from the FRAIR package to test for type-II versus type-III functional responses within ...
2
votes
1
answer
72
views
Remove duplicate names while replacing underscores with spaces in R
I have last names (left) and first names (right) separated by a comma.
Among the last names, I often (but not always) have duplicates separated by an underscore. How to remove the duplicates and, for ...
2
votes
4
answers
84
views
how to populate column based on multiple types of strings in other column
I have a data set of behavioral data. I want to assign all the different behaviors as "aggressive", "submissive", "affiliative", or leave blank in a column of the data ...
3
votes
4
answers
93
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 ...
4
votes
4
answers
115
views
Separting alphanumeric string using tidyr separate wider regex
I have the following data,
id <- c("case1", "case19", "case88", "case77")
vec <- c("One_20 (19)",
"tWo_20 (290)",
&...
5
votes
4
answers
141
views
how to find unique characters both in forward and backward order in R
I have a list of characters like this:
list <- c('a_b', 'a_c', 'a_d', 'a_e', 'a_b', 'b_a', 'b_c', 'b_c','c_b')
I want to have a list of unique characters with no more 'b_a', 'c_b'.
I have tried ...
2
votes
3
answers
92
views
Rearrage string elements by the number attached with it in rows
I have this data frame,
set.seed(124)
id <- rnorm(5, mean = 100, sd = 59)
charVar <- c("Eeny (2), meeny (10), miny (21), moe (1)",
"Catch (112), a (2), tiger (33), by (44), the (...
1
vote
3
answers
81
views
Method for finding reversed names in variable
I am working with large administrative data and have found that there are correctly-ordered names and names that are ordered in the reverse (definitely expected, but I haven't had to parse such errors ...
1
vote
1
answer
63
views
mixed date converted from default mm/dd/yy in excel to dd/mm/yy
I have a very messy date column like this in excel:
For example, the row which the row_id=23 in excel is input as dd/mm/yy format, so it should be read as 2023-09-07 when I import this worksheet into ...
2
votes
3
answers
107
views
How do I replace values from a matrix to another list when certain words/conditions are met in R programming?
I have a matrix of raw data, we can call it Matrix supermarketproducts with several details of supermarket products, such as the name, brand and description for example. I used the readxl function to ...
2
votes
3
answers
84
views
How do I make a function to create new columns with true and false for each of multiple options contained within one column?
I have a database with a large number of columns which contain multiple options from a selection. I need to pivot all of these into true or false columns so that they can be analysed in PowerBI.
...