Displaying 20 results from an estimated 30000 matches similar to: "extending strsplit to handle missing text that doesn't have the target on which to split"
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
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]
2012 Mar 27
1
matrix(unlist(strsplit(""))) 'missing value' issue
*I'm still a R noob, just had a couple of lectures about it in our research
master.
There is a Deal or no deal experiment where I have to write some code for.
Someone wrote a website to gather the data and write it in a .xlsx file.
These are seperate files for seperate participants so first I have to import
the seperate datafiles. I do that like this:
# Merge the xlsx files into one dataframe
2010 Jan 18
3
Using the output of strsplit
I successfully combined my data frames, and am now on my next hurdle.
I had combined the data and quarter, and used tapply to count the
entries for each unique date/quarter pair.
ar= tapply(ewrgnd$gw, list(ewrgnd$dq), sum) #for each date/quarter
combination sums the gw (which are all 1)
dq=row.names(ar)
spl=strsplit(dq)
But I need to split them back into the separate date and quarter. So I
used
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,
2009 Apr 10
4
split a character variable into several character variable by a character
Dear Mao Jianfeng,
"r-help-owner" is not the place for help, but:
r-help at r-project.org
(CC-ed here)
In any case, strsplit() does the job, i.e.:
> unlist(strsplit("BCPy01-01", "-"))
[1] "BCPy01" "01"
You can work with the whole variable, like:
splitpop <- strsplit(df1$popcode, "-")
then access the first part with
>
2012 Feb 11
2
obtaining a true/false vector with combination of strsplit, length, unlist,
Hi,
A pared down version of the dataset I'm working with:
edm<-read.table(textConnection("WELLID X_GRID Y_GRID LAYER ROW COLUMN
SPECIES CALCULATED OBSERVED
w301_3 4428. 1389 2 6 18 1 3558
6490.
w304_12 4836. 6627 2 27 20 1 3509
3228.
02_10_12080 3.6125E+04 13875 1 56 145 1
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]
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:
2009 Sep 07
2
using an array of strings with strsplit, issue when including a space in split criteria
Dear all,
I'm having a problem understanding why a split does not occur with in
the 2nd use of the function strsplit below:
# text strings
> txt <- c("sales to 23 August 2008 published 29 August",
+ "sales to 6 September 2008 published?11 September")
# first use
> strsplit(txt, 'published', fixed=TRUE)
[[1]]
[1] "sales to 23 August 2008 "
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
2012 Sep 07
6
splitting character vectors into multiple vectors using strsplit
Hi folks,
Suppose I create the character vector charvec by
> charvec<-c("a1.b1","a2.b2")
> charvec
[1] "a1.b1" "a2.b2"
and then I use strsplit on charvec as follows:
> splitlist<-strsplit(charvec,split=".",fixed=TRUE)
> splitlist
[[1]]
[1] "a1" "b1"
[[2]]
[1] "a2" "b2"
I was wondering
2009 Jun 11
2
need help with strsplit function
Hi, if I have this string: "a.b.c.d" and I use this function:
unlist(strsplit("a.b.c.d", "\\.")), I get this as my output: "a", "b", "c",
and "d". Is there a way to just split on the first period so I obtain only
two pieces like: "a" and "b.c.d"? Anyways, thanks in advance!
--
View this message in context:
2012 May 02
5
R help!
Hello there, I was wondering if you could help me with a quick R issue.
I have a data set where one of the columns has both date and time in
it, e.g. "12/31/11 23:45" in one cell. I want to use R to split this
column into two new columns: date and time.
One of the problems with splitting here is that when the dates go into
single digits there are no 0's in front of months
2009 May 29
2
strsplit
I am trying split a string and use one part of it to label graphs. I am using strsplit for that. While I am able to split it, how do I access the separated parts.
> filName<-"chrI_2223"
>part<- strsplit(filName,"\\_")
> part
[[1]]
[1] "chrI" "2223"
> part[1]
[[1]]
[1] "chrI" "2223"
I looked up the help archive but did
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 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",
2023 Apr 12
3
Split String in regex while Keeping Delimiter
Hello List,
?
I have a dataset consisting of strings that I want to split while saving the delimiter.
?
Some example data:
?leucocyten + gramnegatieve staven +++ grampositieve staven ++?
?leucocyten ? grampositieve coccen +?
?
I want to split the strings such that I get the following result:
c(?leucocyten +?, ??gramnegatieve staven +++?, ??grampositieve staven ++?)
c(?leucocyten ??, ?grampositieve
2008 Jun 25
1
expression, strsplit, ...
DeaR list,
I'm a bit lost in the behavior of substitute and co.
I often use fairly long axis labels in my graphs (long to write, that
is). Typically, they would contain some greek letters and units with
exponents, as in:
> xlab=expression(paste("text ", alpha, " / ", V,".", m^{-3}, ".",
> kg^{-2}, ".", l^{4}))
To make this a
2011 Oct 24
1
strsplit convert data
I am using the following code but I do not know the debug and run for
correct errors
library (tcltk)
file <-tclvalue (tkgetOpenFile ())
if (nchar (file))
{
tkmessageBox ("Select the file")
}
else
{
tkmessageBox (message = paste ("Was select file", file))
Dataset <- read.table (file, header = FALSE, sep = "", na.strings =