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
-1
votes
3 answers

How can I split a text using upper cases follow (blabla) - in R

I have text data that include parliamentary speeches like this: df <- "MEHMET ALİ ÇELEBİ (İzmir) – Teşekkürler Sayın Başkan. 26-30 Haziran Özel Güvenlik Görevlileri Haftası’ndayız, kutluyorum. Bugün ülkemizde 350 bini aşkın özel güvenlik…
-1
votes
1 answer

How to access certain part of a string in python?

I have a string which looks like this: 0,1,488,332,165;1,1,553,712,206;2,1,803,1248,219;3,1,2222,1285,398 The actual string is way more longer than this ... I need to access the 488, 553, 803 and 2222 but the problem is that these values change. I…
john78
  • 37
  • 5
-1
votes
1 answer

How to split string and iterate in php

I would like to know how to know how to split the string by | and - and and display the values in php I have string which i need to split by |and then - and display the value in php
sen
  • 91
  • 7
-1
votes
1 answer

Splitting strings in SQLite

Does anyone know how to split my address columns. I would like to divide it into three new columns, seperated by it's commas. For example 1808 FOX CHASE DR, GOODLETTSVILLE, TN is divided into 1808 FOX CHASE DR GOODLETTSVILLE TN So far I've…
-1
votes
2 answers

Splitting a string that has a not-space hyphen

I have strings such as the following: 2 - 5-< 2 6 - 10-< 2 6 - 10-2 - 5 > 15-2 - 5 I want to split those string just in the point where the - is neither preceded nor followed by blank space. Therefore, the strings above would get split as…
mbistato
  • 139
  • 1
  • 7
-1
votes
1 answer

Python - replace part of the string inside of all files within given directory with previously splitted string

I have a lot of files inside of directory containing some paths. Need to go through all files, and replace first part of the "path" with other one which is I previously got. Have in mind that 'sw' will always be a border between those 2 parts after…
John
  • 230
  • 2
  • 12
-1
votes
3 answers

dataframe how to split column by comma, but ignore those comma in double quotes

I have some questions about pandas dataframe reading csv file, and split column by comma. I have a csv file with only 1 column(with multiple rows, and I have to split column by comma. assume the the dataframe is like "a", "b", 2021-05-01 00:00:00, …
user3429999
  • 17
  • 1
  • 7
-1
votes
1 answer

How can i Split data in R?

I want to split data on various factor like below my data : "vs=1;am=0" fetched from one column from excel file I want an output as below: vs am 1 0 I have tried: s <- unlist(strsplit(Condition, split = ";")) s <- strsplit(s, split = "=") data<-…
-1
votes
2 answers

R: How to split string into pieces

I'm trying to split tons of strings as below: x =…
Zhenyu Wu
  • 3
  • 2
-1
votes
1 answer

How do i atribbute different parameters to the function strsplit(split = " ")?

as the title of the question says, i want to know how do i atribbute different parameters to the function strsplit(x, split = " ") If i apply it, i get every word in my string as a single vector, when it is separeted by space-bar. Ok. But the point…
-1
votes
3 answers

strsplit it by the last "number_"

Hello I have a df such as COL1 SEQ_1.1_0 SEQ2.2_2 AB_1_2.3_3 ACC.3_3 and I would like to strsplit it by the last "number_" and get : COL1 COL2 SEQ_1.1 0 SEQ2.2 2 AB_1_2.3 3 ACC.3 3 so far I tried: strsplit(df$COL1, "*.[0-9]_") here…
chippycentra
  • 3,396
  • 1
  • 6
  • 24
-1
votes
2 answers

Why does paste() concatenate list elements in the wrong order?

Given the following string: my.str <- "I welcome you my precious dude" One splits it: my.splt.str <- strsplit(my.str, " ") And then concatenates: paste(my.splt.str[[1]][1:2], my.splt.str[[1]][3:4], my.splt.str[[1]][5:6], sep = " ") The result…
Antsushi
  • 167
  • 10
-1
votes
1 answer

How to string splitting in R?

I have a data frame like this : Screen.name party users 1 A_Gloeckner SPD @MartinSchulz. 2 A_Gloeckner SPD @MartinSchulz 3…
Eyayaw
  • 1,033
  • 5
  • 10
-1
votes
1 answer

Splitting a character column into multiple columns

y <- data.frame(x = c("63,98,131","75,109,145","66,104,139")) I want to make three columns A,B,C from x by splitting from comma A B C 63 98 131 75 109 145 66 104 139 I tried to use str_split str_split(y$x, " , ") [[1]] [1] "63,98,131" …
89_Simple
  • 3,393
  • 3
  • 39
  • 94
-1
votes
1 answer

Splitting vector to get middle value

I have few column names from which I need to get middle string. For example; From this list "RHC3934__Bcell__.7DEA7B","RHC3944__Bcell__.7DEA7B", "RHC3962__Tcell__.C6E879", "RHC4003__Bcell__.7DEA7B", "RHC4005__Bcell__.7DEA7B",…
user44552
  • 153
  • 1
  • 10