Displaying 20 results from an estimated 6000 matches similar to: "strsplit on comma, with a trailing comma in input"
2011 Feb 04
3
lapply, strsplit, and list elements
Hi there,
I have a problem about lapply, strsplit, and accessing list elements,
which I don't understand or cannot solve:
I have e.g. a character vector with three elements:
x = c("349/077,349/074,349/100,349/117",
"340/384.2,340/513,367/139,455/128,D13/168",
"600/437,128/903,128/904")
The task I want to perform, is to generate a list,
2006 Apr 17
1
strsplit does not return correct value when spliting "" (PR#8777)
Full_Name: Charles Dupont
Version: 2.2.0
OS: linux
Submission from: (NULL) (160.129.129.136)
when
strsplit("", " ")
returns character(0)
where as
strsplit("a", " ")
returns "a".
these return values are not constiant with each other.
Charles Dupont
2012 Apr 11
1
strsplit help
Dear all,
I want to use string split to parse column names, however, I am having
some errors that I don't understand.
I see a problem when I try to rbind the output from strsplit.
please let me know if I'm missing something obvious,
thanks,
alison
here are my commands:
>strsplit<-strsplit(as.character(Rumino_Reps_agreeWalign$geneid),"\\.")
>
2007 Oct 22
3
strsplit
Hello R Gurus:
I would like to take a character string and split at the $ sign.
I thought that strsplit would do it, but here are the results:
> vv
[1] "whine$ts1"
> vv
[1] "whine$ts1"
> strsplit(vv,"$")
[[1]]
[1] "whine$ts1"
Does anyone have any suggestions, please?
Thanks,
Edna Bell
2006 Aug 29
3
Substring and strsplit
Dear R People:
I am trying to split a character vector into a set of individual
letters:
Ideal:
x3 <- c("dog")
"d" "o" "g"
I tried the following:
> strsplit(x3)
Error in strsplit(x3) : argument "split" is missing, with no default
> strsplit(x3,1)
[[1]]
[1] "dog"
I know that this is incredibly simple, but what am I doing
2009 Sep 17
2
Why strsplit can be used with matrix but not data.frame?
Hi,
As show in the code below, strsplit can be applied to a matrix but not
a data.frame. I don't understand why R is designed in this way. Can
somebody help me understand it? How to split all the strings in x$y?
x=data.frame(x=1:10,y=rep("abc",10))
strsplit(x$y,'b') #Error in strsplit(x$y, "b") : non-character argument
y=cbind(1:10,rep("abc",10))
2012 Jan 25
4
help to slip a file name using "strsplit" function
Dear Researchers,
I have several files as this example: Myfile_MyArea1_sample1.txt
i wish to split in "Myfile", "MyArea1", "sample1", and "txt", becasue i
need to use "sample1" label. I try to use "strsplit" but I am able just to
split as "Myfile_MyArea1_sample1" and "txt" OR "Myfile", "MyArea1",
2012 Mar 22
2
Strsplit with a separator of ||
Hi,
I tried to use strsplit for separating a string with || like
strsplit(string,"\\||") but it returned each single character was separated.
For example:
strsplit("a||bc","\\||")
[[1]]
[1] "a" "" "" "b" "c"
where I want the result to be "a" and "bc".
Any ideas?
Thanks!
Best,
2011 Aug 03
2
strsplit and forward slash '/'
Hi All,
is there a way of using strsplit with a forward slash '/' as the splitting point?
For data such as:
1 T/T C/C 16/33
2 T/T C/C 33/36
3 T/T C/C 16/34
4 T/T C/C 16/31
5 C/C C/C 28/29
6 T/T C/C 16/34
strsplit(my.data[1,1], "/") # and any variation thereof
Error in strsplit(apoe[1, 1], "/") : non-character
2012 Jan 12
3
strsplit() does not split on "."?
Any ideas what is wrong?
> strsplit("a.b", ".") # generates empty strings with split="."
[[1]]
[1] "" "" ""
> strsplit("a b", " ") # seems to work fine with split=" ", and other
characters...
[[1]]
[1] "a" "b"
>
> R.Version()
$platform
[1]
2006 Apr 04
1
extending strsplit(): supply pattern to keep, not to split by
strsplit() is a convenient way to get a
list of items from a string when you
have a regular expression for what is not
an item. E.g.,
> strsplit("1.2, 34, 1.7e-2", split="[ ,] *")
[[1]]:
[1] "1.2" "34" "1.7e-2"
However, sometimes is it more convenient to
give a pattern for the items you do want.
E.g., suppose you want to pull
2005 Oct 28
1
Error in ?strsplit
Hi all,
Came across an error in ?strsplit in the details section:
Details:
Arguments 'x' and 'split' will be coerced to character, so you
will see uses with 'split = NULL' to mean 'split = character(0)',
including in the examples below.
I caught myself trying to use strsplit() on a factor and the coercion on
'x' is not done.
According
2010 Jul 08
2
strsplit("dia ma", "\\b") splits characterwise
\b is word boundary.
But, unexpectedly, strsplit("dia ma", "\\b") splits character by character.
> strsplit("dia ma", "\\b")
[[1]]
[1] "d" "i" "a" " " "m" "a"
> strsplit("dia ma", "\\b", perl=TRUE)
[[1]]
[1] "d" "i" "a" " "
2012 Nov 08
3
strsplit with invalid regular expression
Hi all,
> diff_operator <- "\\("
> strsplit(cond, diff_operator)
[[1]]
[1] "andsin" "log_angle_1_4)"
> diff_operator <- "\\sin("
> strsplit(cond, diff_operator)
Error in strsplit(cond, diff_operator) :
invalid regular expression '\sin(', reason 'Missing ')''
When I am going to split with "("
2007 Sep 09
2
Problems with strsplit
Hello,
I would like to know what can I do if I use strplit with a string and I want to use the middle left,I mean I have this:
strsplit("bA531F16-rep","\\-")
[[1]]
[1] "bA531F16" "rep"
I would like to work just with bA531F16 in another variable, what could I do?, Thank you
---------------------------------
Sé un Mejor Amante
2013 Sep 18
2
strsplit with a vector split argument
Hi,
I find this behavior unexpected:
--8<---------------cut here---------------start------------->8---
> strsplit(c("a,b;c","d;e,f"),c(",",";"))
[[1]]
[1] "a" "b;c"
[[2]]
[1] "d" "e,f"
--8<---------------cut here---------------end--------------->8---
I thought that it should be identical to this:
2019 Dec 18
2
A weird behaviour of strsplit?
Hi all,
In the help of strsplit one can read
split character vector (or object which can be coerced to such) containing regular expression<http://127.0.0.1:39783/help/library/base/help/regular%20expression>(s) (unless fixed = TRUE) to use for splitting. If empty matches occur, in particular if split has length 0, x is split into single characters. Ifsplit has length greater than 1, it is
2011 Oct 12
5
strsplit question
Dear R People:
I have the following set of data
> Block[1:5]
[1] "5600-5699" "6100-6199" "9700-9799" "9400-9499" "8300-8399"
and I want to split at the -
> strsplit(Block[1:5],"-")
[[1]]
[1] "5600" "5699"
[[2]]
[1] "6100" "6199"
[[3]]
[1] "9700" "9799"
[[4]]
[1]
2008 Apr 11
3
strsplit and sapply
Colleagues,
I have some text:
TEXT <- c("a", "bb;ccc", "dddd;eeeee;ffffff")
I want to retrieve the portion of each element before the first
semicolon. I can split each element using strsplit:
SPLIT <- strsplit(TEXT, ";")
This yields:
> SPLIT
[[1]]
[1] "a"
[[2]]
[1] "bb" "ccc"
[[3]]
[1] "dddd"
2010 Dec 14
2
Selecting non-empty elements after strsplit of string
Hello,
I am attempting to manipulate strings in which there are differing amounts of whitespace before and after each element taht I want to keep (any word, letter, or number). However, after strsplit and unlist, I know how to select specific elements with "[ ]", but I want to select instead all elements that are not missing. That is, do not select any elements that are simply