Questions tagged [strsplit]

strsplit is a function in R and MATLAB which splits the elements of a character vector around a given delimiter.

strsplit is a function in R (documentation) and MATLAB (documentation), which splits the elements of a character vector into substrings:

# R:  
strsplit(x, split, fixed=FALSE)
% MATLAB
strsplit(x, split);

Splits a character string or vector of character strings using a regular expression or a literal (fixed) string. The strsplit function outputs a list (R) or cell array (MATLAB), where each list item corresponds to an element of x that has been split.

  • x a character string or vector of character strings to split.
  • split the character string to split x.
    In R, if split is an empty string (""), then x is split between every character.
  • [R only:] fixed if the split argument should be treated as fixed (i.e. literally). By default, the setting is FALSE, which means that split is treated like a regular expression.
702 questions
0
votes
1 answer

Create column, separated by "," as a numeric output

I am trying to present data that is currently in rows as "XXX-XX-0001, YY-YY-0001" into a new column, outlining the number within each row [2] I have managed to mutate a new column, however it is a character output chr [2], i need this to be just…
HP.
  • 37
  • 5
0
votes
1 answer

Using strsplit results in terms with quotation marks in r

I have a large set of data, which I have imported from excel. I wish to get term frequency table for the data set. But, when I use strspplit, it includes quotation marks and other punctuation which gives wrong results. There is a small error in the…
Ojaswita
  • 83
  • 10
0
votes
0 answers

How to Create a New column to insert data after str_split

I'm simply trying to take a column with game scores formatted like so "0-0", "0-2", etc. I want each teams score in a separate column which seems tailor made to use the "-" as the split key. I was able to use the following code to create a data…
Jeff Henderson
  • 643
  • 6
  • 10
0
votes
1 answer

How to check splitted values of a column without changing the dataframe?

I am trying to find columns hitting specific conditions and put a value in the column col. My current implementation is: df.loc[~(df['myCol'].isin(myInfo)), 'col'] = 'ok' In the future, myCol will have multiple info. So I need to split the value in…
thestruggleisreal
  • 940
  • 3
  • 10
  • 26
0
votes
1 answer

In AHK, how do I properly use StrSplit to create an array out of a CSV file, then parse through it under specific criteria?

I want to take a CSV that has four parts: Some text to be displayed, a priority rating, a duration in ms, and a "start time" in ms Then select from the rows the row with the lowest start time (or in case of a tie, the one with the highest…
0
votes
1 answer

Split Column by multiple delimiters and order

I am trying to analyze some daily fantasy lineups and need to split the lineup column into multiple columns, one for each position. I would like the delimiters to be the positions ("P", "C", "1B", "2B", "SS", "3B", "OF"). I have tried to use…
0
votes
0 answers

Splitting a character by "." in R

The following character needs to be split by "." value <- "abcdefg.csv" strsplit(value,".") The output that I get is: [[1]] [1] "" "" "" "" "" "" "" "" "" "" "" However, what I want is: [[1]] [1] "abcdefg" "csv"
Qwerty
  • 869
  • 1
  • 5
  • 18
0
votes
2 answers

R split string and keep section

I have a string containing the starting lineup (extracted from the web) for a rugby game, it looks like this: "Crusaders: 15 David Havili, 14 Seta Tamanivalu, 13 Jack Goodhue, 12 Ryan Crotty, 11 George Bridge, 10 Richie Mo’unga, 9 Bryn Hall, 8…
Liam Young
  • 11
  • 3
0
votes
3 answers

I need to pull a specific string from a URL path

I am pulling the following URL from a JSON on the internet. Example of the string I am working with: http://icons.wxug.com/i/c/k/nt_cloudy.gif I need to get just the "nt_cloudy" from the above in order to write the img (already stored) to an epaper…
0
votes
1 answer

Split list into dataframe at comma delimiter

This may be a duplicate, but after some time I still have not found a simple, adequate answer for R. I have a list answers containing comma delimited data of varying types (numbers, characters, strings, dates) in numerous rows. How do I split it up…
user72716
  • 263
  • 3
  • 22
0
votes
2 answers

Separation and pattern matching according occurrence time

I would like to separate the dates inside of text in my data frame. My data look like this: tt <- structure(list(V1 = c("(Q)üfür (2013)", "'Bi atlayip çikicam' cümlesini fazla ciddiye aldiysak zaar (2016)", "A'dan Z'ye (o biçim) (1975)", "Gün…
eabanoz
  • 251
  • 3
  • 17
0
votes
1 answer

r Separate numbers with "/" in grouped data frame

I have a large dataframe that looks like the following example: Say that there is a ball game, where you can throw the ball to hit a target and get points. There is a team A and B, and everyone can decide how many times they want to throw the ball…
Lotw
  • 423
  • 1
  • 4
  • 15
0
votes
1 answer

rowwise strsplit

I have the following code: data <- data_frame(job_id = c("114124", "114188", "114206"), project_skills = c("WordPress,XTCommerce,Magento,Prestashop,VirtueMart,osCommerce", "HTML,SEO,WordPress,SEO Texte", "Illustrator,Graphic…
Tobias Mini
  • 380
  • 2
  • 12
0
votes
1 answer

C file to multiple char *groups by word delimiter

I have a file with content similar to below: Really my data is here, and I think its really cool. Somewhere, i want to break on some really awesome data. Please let me really explain what is going '\n' on. You are amazing. Something is really…
johnnyb
  • 1,745
  • 3
  • 17
  • 47
0
votes
2 answers

R - Document Term Matrix with comma separated text column entries

I´ve got a data frame with a column consisting of Strings (project_skills) which denotes the skills a certain job (job_id) affords. I want to split this string for every job to get an vector of the skills a job affords and then create a Document…
Tobias Mini
  • 380
  • 2
  • 12