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:
On Sep 18, 2013, at 10:42 AM, Sam Steingold s...@gnu.org wrote:
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
to
read.
H.
#[[1]]
#[1] a b c
#
#[[2]]
#[1] d e f
A.K.
- Original Message -
From: Sam Steingold s...@gnu.org
To: r-help@r-project.org
Cc:
Sent: Wednesday, September 18, 2013 11:42 AM
Subject: [R] strsplit with a vector split argument
Hi,
I find this behavior unexpected:
--8
Hi,
You could try:
strsplit(c(a,b;c,d;e,f),,|;)
#[[1]]
#[1] a b c
#
#[[2]]
#[1] d e f
A.K.
- Original Message -
From: Sam Steingold s...@gnu.org
To: r-help@r-project.org
Cc:
Sent: Wednesday, September 18, 2013 11:42 AM
Subject: [R] strsplit with a vector split argument
Hi,
I find
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 ( it’s
strsplit()asdasdsin(abcd), sin\\()
[[1]]
[1] )asdasd abcd)
On Thu, Nov 8, 2012 at 12:39 PM, Bharat Warule bwar...@gmail.com wrote:
Hi all,
diff_operator - \\(
strsplit(cond, diff_operator)
[[1]]
[1] andsin log_angle_1_4)
diff_operator - \\sin(
strsplit(cond,
HI,
cond-andsin(log_angle_1_4)
diff_operator-sin\\(
strsplit(cond,diff_operator)
#[[1]]
#[1] and log_angle_1_4)
A.K.
- Original Message -
From: Bharat Warule bwar...@gmail.com
To: r-help@r-project.org
Cc:
Sent: Thursday, November 8, 2012 6:39 AM
Subject: [R] strsplit
In R, the source code representation of a special character uses the \ as an
escape character to begin a special character sequence. For example, \n is a
single newline character.
Because backslash has this special meaning, to represent a single backslash
character one must escape it: \\ looks
Thanks - I checked through and it looks as if all of the geneids are
formatted similarily so I don't know which one would be causing an error.
Interestingly, your sapply method works on the same data. So I'm happy
although still confused, because the strsplit method worked the other
day with a
Alison,
You've got two geneids with two periods (instead of just one period).
gene.list - strsplit(as.character(Rumino_Reps_agreeWalign$geneid),\\.)
Rumino_Reps_agreeWalign[sapply(gene.list, length)!=2, ]
geneid count_Conser count_NonCons count_ConsSubst
count_NCSubst
7
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:
Alison,
Your code works fine on the first six lines of the data that you provided.
Rumino_Reps_agreeWalign - data.frame(
geneid = c(657313.locus_tag:RTO_08940,
457412.251848018,
657314.locus_tag:CK5_20630,
657323.locus_tag:CK1_33060,
On Apr 11, 2012, at 2:01 PM, Jean V Adams wrote:
Alison,
Your code works fine on the first six lines of the data that you
provided.
Rumino_Reps_agreeWalign - data.frame(
geneid = c(657313.locus_tag:RTO_08940,
457412.251848018,
David,
Right you are! Thanks for pointing that out.
strsplit - 1:10
strsplit(With spaces, NULL)
strsplit
Jean
David Winsemius dwinsem...@comcast.net wrote on 04/11/2012 01:17:07 PM:
[image removed]
Re: [R] strsplit help
David Winsemius
to:
Jean V Adams
04/11/2012 01:19 PM
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,
Jing
On 22-03-2012, at 08:23, jing tang wrote:
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.
On 22-03-2012, at 08:28, Berend Hasselman wrote:
On 22-03-2012, at 08:23, jing tang wrote:
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]
You need another \\
strsplit(a||bc,\\|\\|)
[[1]]
[1] a bc
On Thu, Mar 22, 2012 at 3:23 AM, jing tang jing.t...@fimm.fi wrote:
Hi,
I tried to use strsplit for separating a string with || like
strsplit(string,\\||) but it returned each single character was separated.
For example:
Thanks!
JIng
-Original Message-
From: Berend Hasselman [mailto:b...@xs4all.nl]
Sent: 22. maaliskuuta 2012 9:33
To: Berend Hasselman
Cc: jing tang; r-help@r-project.org
Subject: Re: [R] Strsplit with a separator of ||
On 22-03-2012, at 08:28, Berend Hasselman wrote:
On 22-03-2012
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] x86_64-unknown-linux-gnu
$arch
[1] x86_64
$os
[1] linux-gnu
$system
[1] x86_64,
Reread the help for strsplit:
## Note that 'split' is a regexp!
## If you really want to split on '.', use
unlist(strsplit(a.b.c, \\.))
## [1] a b c
## or
unlist(strsplit(a.b.c, ., fixed = TRUE))
For your example:
strsplit(a.b, \\.)
[[1]]
[1] a b
In other words,
Hi Ryszard,
Try
strsplit(a.b, [.])[[1]]
and see Extended Regular Expressions in ?regexp.
HTH,
Jorge,-
On Thu, Jan 12, 2012 at 10:15 AM, Czerminski, Ryszard wrote:
Any ideas what is wrong?
strsplit(a.b, .) # generates empty strings with split=.
[[1]]
[1]
strsplit(a b, ) # seems
-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Czerminski, Ryszard
Sent: Thursday, January 12, 2012 10:16 AM
To: r-help
Subject: [R] strsplit() does not split on .?
Any ideas what is wrong?
strsplit(a.b, .) # generates empty strings with split=.
[[1]]
[1
unlist(strsplit(Block[1:5], -.+$))
if you are going to want the other pieces later, the most efficient
way depends on the assumptions you can make about your data. If there
are always two elements from the split:
matrix(unlist(strsplit(Block[1:5], -)), ncol = 2, byrow = TRUE)
## or
sapply(strsplit(Block[1:5],-), function (x) {x[1]})
comes to mind...
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer
Hi Erin,
this is one way:
Block - c(5600-5699,6100-6199,9700-9799,9400-9499,8300-8399)
splBlock - strsplit(Block,-)
sapply(splBlock, [, 1)
greetings,
Remko
--
View this message in context:
http://r.789695.n4.nabble.com/strsplit-question-tp3896847p3896850.html
Sent from the R help
On Oct 12, 2011, at 1:20 AM, Erin Hodgess wrote:
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]
On Wed, Oct 12, 2011 at 1:20 AM, Erin Hodgess erinm.hodg...@gmail.com wrote:
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
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] 9400 9499
[[5]]
[1] 8300 8399
What is the best way
Hi All,
is there a way of using strsplit with a forward slash '/' as the splitting
point?
For data such as:
1 T/TC/C 16/33
2 T/TC/C 33/36
3 T/TC/C 16/34
4 T/TC/C 16/31
5 C/CC/C 28/29
6 T/TC/C 16/34
strsplit(my.data[1,1], /) # and any
On 03/08/2011 12:37 PM, Federico Calboli wrote:
Hi All,
is there a way of using strsplit with a forward slash '/' as the splitting
point?
For data such as:
1 T/TC/C 16/33
2 T/TC/C 33/36
3 T/TC/C 16/34
4 T/TC/C 16/31
5 C/CC/C 28/29
6 T/T
Hi Federico,
A forward slash isn't a special character:
strsplit(T/T, /)
[[1]]
[1] T T
so there's some other problem.
Are you sure that your first column contains strings and not factors?
What does str(my.data) tell you?
Does
strsplit(as.character(my.data[1,1]), /)
work?
If you used
On 3 Aug 2011, at 17:41, Duncan Murdoch wrote:
It looks as though your my.data[1,1] value is a factor, not a character value.
strsplit(as.character(my.data[1,1]), /)
Thanks Duncan, this solved it.
Best
Federico
would work, or you could avoid getting factors in the first place,
On 3 Aug 2011, at 17:46, Sarah Goslee wrote:
Hi Federico,
A forward slash isn't a special character:
strsplit(T/T, /)
[[1]]
[1] T T
so there's some other problem.
Are you sure that your first column contains strings and not factors?
What does str(my.data) tell you?
Does
Newbie question ...
I am looking something equivalent to read.delim but which accepts a text line
as parameter instead of a file input.
Below is my problem, I'm unable to get the exact output which is a simple data
frame of the data where the delimiter exists ... coming quite close though
I
Is this what you are after:
x - c(Scheme Code;Scheme Name;Net Asset Value;Repurchase Price;Sale
Price;Date
+ ,
+ ,Open Ended Schemes ( Liquid )
+ ,
+ ,
+ , AIG Global Investment Group Mutual Fund
+ , 106506;AIG India Liquid Fund-Institutional Plan-Daily Dividend
Jim's solution is the ideal way to read in the data: using the sep=;
argument in read.table.
However, if you do for some reason have a vector of strings like the
following (maybe someone gives you an Rdata file instead of the raw
data file):
MF_Data - c(106506;AIG India Liquid Fund-Institutional
On Oct 9, 2010, at 12:46 PM, Jeffrey Spies wrote:
Jim's solution is the ideal way to read in the data: using the sep=;
argument in read.table.
However, if you do for some reason have a vector of strings like the
following (maybe someone gives you an Rdata file instead of the raw
data file):
Obviously Jim's solution does work, and I did not intend to imply it
didn't. In fact, his read.table solution would work both if the OP
had a semi-colon delimited file to begin with (which I was trying to
say was ideal from a workflow standpoint) or a vector of strings (for
use when paired with
Thanks Jim. Exactly what I needed!
-Original Message-
From: jim holtman [mailto:jholt...@gmail.com]
Sent: 09 October 2010 22:01
To: Santosh Srinivas
Cc: r-help@r-project.org
Subject: Re: [R] StrSplit
Is this what you are after:
x - c(Scheme Code;Scheme Name;Net Asset Value;Repurchase
\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 m a
How can that be?
This is the output of 'gregexpr'.
gregexpr(\\b, dia ma)
[[1]]
[1] 1 2 3 4 5 6
l guess this is expected behaviour, although counterintuitive. \b
represents an empty string indicating a word boundary, but is coerced
to character and thus simply the empty string. This means the output
you get is the same as
strsplit(dia ma, ,perl=T)
[[1]]
[1] d i a m a
I'd use the
On Thu, Jul 8, 2010 at 4:15 AM, Suharto Anggono Suharto Anggono
suharto_angg...@yahoo.com wrote:
\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 m a
Hello!
I have the following problem:
I have a file in R that has in the first row three informations in one
row that I would like to in three different rows.
The first row looks like this:
GenusA_SpeciesC_Tree
GenusA_SpeciesF_Tree
GenusB_SpeciesA_Shrub
...
I tried with strsplit and and
How about this:
testdata - data.frame(sp = c(GenusA_SpeciesC_Tree,
GenusA_SpeciesF_Tree, GenusB_SpeciesA_Shrub),
stringsAsFactors=FALSE)
# for one
unlist(strsplit(testdata[1,1], split=_))
# for all of them
do.call(rbind, sapply(testdata[,1], strsplit, split=_))
Sarah
On Tue, Jun 1, 2010 at
Hi,
I don't know if it would help you since your goal is not really clear to
me, but here are some thoughts:
x - c(GenusA_SpeciesC_Tree, GenusA_SpeciesF_Tree,
GenusB_SpeciesA_Shrub)
test - strsplit(x, _)
test
[[1]]
[1] GenusA SpeciesC Tree
[[2]]
[1] GenusA SpeciesF Tree
[[3]]
[1]
This might not be the most elegant way of doing it, but it should probably
work, given that data is always separated by a _.
string.1-strsplit(c(GenusA_SpeciesC_Tree,GenusA_SpeciesF_Tree,
GenusB_SpeciesA_Shrub),_)
matrix(unlist(string.1),ncol=3,byrow=TRUE)
2010/6/1 Joël Baumann
Another option is to use the colsplit() function (in the reshape package):
testdata - data.frame(sp = c(GenusA_SpeciesC_Tree,
GenusA_SpeciesF_Tree, GenusB_SpeciesA_Shrub),
stringsAsFactors=FALSE)
library(reshape)
testdata - cbind(testdata, colsplit(testdata$sp, split=_, names=c(Genus,
Species,
There are two ways to express file paths with the Windows environment:
a=file.choose()
a
[1] C:\\Documents and Settings\\rbaer\\Desktop\\_VNT_Test\\coordFocused 20k F5
0ng Ki8751 t20.txt
and
b= paste(getwd(),/,dir()[1],sep=)
b
[1] C:/Documents and Settings/rbaer/Desktop/_VNT_Test/coordFocused
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Robert Baer
Sent: Thursday, October 29, 2009 12:40 PM
To: r-help@r-project.org
Subject: [R] strsplit() and Windows file paths
There are two ways to express file paths
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Nordlund, Dan (DSHS/RDA)
Sent: Thursday, October 29, 2009 12:57 PM
To: r-help@r-project.org
Subject: Re: [R] strsplit() and Windows file paths
-Original Message
Dear all,
I am trying to split a matrix into 2 as efficiently as possible.
It is a character matrix:
1 2 3
1 2-271 2-367 1-79
2 2-282 2-378 1-90
3 2-281 2-377 1-89
I want to make 2 matrices from this, as succinctly and efficiently as
possible.
I've tried such things as
one way us the following:
mat - rbind(
c(2-271, 2-367, 1-79),
c(2-282, 2-378, 1-90),
c(2-281, 2-377, 1-89)
)
sp - strsplit(c(mat), -)
mat1 - sapply(sp, [, 1)
mat2 - sapply(sp, [, 2)
dim(mat1) - dim(mat2) - dim(mat)
mat1
mat2
I hope it helps.
Best,
Dimitris
James Perkins wrote:
Try this:
#1
gsub(.*-, , zzz)
#2
gsub(-.*, , zzz)
On Mon, Aug 10, 2009 at 1:56 PM, James Perkins
jperk...@biochem.ucl.ac.ukwrote:
Dear all,
I am trying to split a matrix into 2 as efficiently as possible.
It is a character matrix:
1 2 3 1 2-271 2-367 1-79
2 2-282
Try this:
#1
gsub(.*-, , zzz)
#2
gsub(-.*, , zzz)
#3)
gsub(.*-(.*)-.*, \\1, zzz)
On Mon, Aug 10, 2009 at 4:20 PM, Jun Shen jun.shen...@gmail.com wrote:
Henrique,
This is a very nice approach. I wonder what if I have data like 2-172-45
and want to break it down into three parts 2, 172 and
Henrique,
This is a very nice approach. I wonder what if I have data like 2-172-45 and
want to break it down into three parts 2, 172 and 45. How do we use your
method to achieve it? Thanks.
Jun
On Mon, Aug 10, 2009 at 12:34 PM, Henrique Dallazuanna www...@gmail.comwrote:
Try this:
#1
Henrique Dallazuanna wrote:
Try this:
unlist(part)[1]
or
part[[1]][1]
And in order to isnpect your objects, use
str(part)
at first which tells you about the structure of the object. Then you
know you got a list and can look up how to extract a part of a list as
Henrique Dallazuanna
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
Try this:
unlist(part)[1]
or
part[[1]][1]
On Fri, May 29, 2009 at 2:09 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
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.
#how do I break these up into first two letters (RM), number, and then
the last part
#is there an easily accessible regex tutorial on the internet?
v = (structure(1:122, .Label = c(RM215Temp, RM215SpCond, RM215DO.Conc,
RM215Depth, RM215pH, RM215ORP, RM215Turbidity., RM215Battery,
RM215DO.,
stephen sefick ssefick at gmail.com writes:
#how do I break these up into first two letters (RM), number, and then
the last part
#is there an easily accessible regex tutorial on the internet?
For regular expressions, the perl man pages at http://perldoc.perl.org/
perlre.html are quite good
You can do this one even more easily without regular
expressions like this:
substring(v, 1, 2)
substring(v, 3)
or with regexps:
sub((..).*, \\1, v)
sub(..(.*), \\1, v)
or in one line using strapply in the gsubfn package:
library(gsubfn) # see http://gsubfn.googlecode.com
out -
Hi All,
Is there a means to extract the 10 from 23:10:34 in one pass using
strsplit (or something else)?
tst - 23:10:34
For example my attempt
strsplit(as.character(tst),^[0-9]*:)
gives
[[1]]
[1] 34
Obviously it is matching the first two instances of [0-9]. Note that
there may be only
To: r-help@r-project.org
Subject: [R] strsplit and regex
Hi All,
Is there a means to extract the 10 from 23:10:34 in one
pass using strsplit (or something else)?
tst - 23:10:34
For example my attempt
strsplit(as.character(tst),^[0-9]*:)
gives
[[1]]
[1] 34
Obviously it is matching
Matthew -
Redding, Matthew wrote:
Hi All,
Is there a means to extract the 10 from 23:10:34 in one pass using
strsplit (or something else)?
tst - 23:10:34
For example my attempt
strsplit(as.character(tst),^[0-9]*:)
gives
[[1]]
[1] 34
Why not simply,
strsplit(tst, :)
at which point
]
[mailto:[EMAIL PROTECTED] On Behalf Of Redding, Matthew
Sent: Thursday, 16 October 2008 7:54 AM
To: r-help@r-project.org
Subject: [R] strsplit and regex
Hi All,
Is there a means to extract the 10 from 23:10:34 in one
pass using strsplit (or something else)?
tst - 23:10:34
For example my attempt
Try this:
format(strptime(tst, %H:%M:%S), %M)
On Wed, Oct 15, 2008 at 6:54 PM, Redding, Matthew
[EMAIL PROTECTED] wrote:
Hi All,
Is there a means to extract the 10 from 23:10:34 in one pass using
strsplit (or something else)?
tst - 23:10:34
For example my attempt
Here are several solutions:
#1
# replace first three and last 3 characters with nothing
x - c(23:10:34, 01:02:03)
gsub(^...|...$, , x)
#2
# backref = -1 says extract the portion in parens
# it would have returned a list so we use simplify = c
library(gsubfn)
strapply(x, :(..):, backref = -1,
Dear list,
I am trying to split a string using regexp:
x - 2 Value 34 a-c 45 t
strsplit(x, [0-9])
[[1]]
[1]Value a-c t
But I don't want to lose the digits (pattern), the result
should be:
[[1]]
[1] 2 Value 34 a-c 45 t
Thanks for any tipp
Patrick
Try this:
library(gsubfn)
strapply(x, [0-9]+| +[^ ]+ *)[[1]]
[1] 2Value 34 a-c45 t
which keeps the spaces around the non-numeric entries as in
your example; however, if keeping the spaces is not important
then its even easier:
strsplit(x, )[[1]]
[1] 2 Value 34
On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
Try this:
library(gsubfn)
x - A: 123 B: 456 C: 678
strapply(x, [^ :]+[ :]|[^ :]+$)
[[1]]
[1] A: 123 B: 456 C: 678
and check out the gsubfn home page at:
http://gsubfn.googlecode.com
Thanks Gabor!
hadley wickham [EMAIL PROTECTED] writes:
n
On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
Try this:
library(gsubfn)
x - A: 123 B: 456 C: 678
strapply(x, [^ :]+[ :]|[^ :]+$)
[[1]]
[1] A: 123 B: 456 C: 678
Also
strsplit(x, (?=[0-9:] ), perl=TRUE)
On Sat, Jun 14, 2008 at 10:20 AM, Martin Morgan [EMAIL PROTECTED] wrote:
hadley wickham [EMAIL PROTECTED] writes:
n
On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
Try this:
library(gsubfn)
x - A: 123 B: 456 C: 678
strapply(x, [^ :]+[ :]|[^ :]+$)
[[1]]
[1]
On Sat, Jun 14, 2008 at 11:46 AM, hadley wickham [EMAIL PROTECTED] wrote:
On Sat, Jun 14, 2008 at 10:20 AM, Martin Morgan [EMAIL PROTECTED] wrote:
hadley wickham [EMAIL PROTECTED] writes:
n
On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
Try this:
Hi all,
Does anyone have a version of strsplit that keeps the string that is
split by. e.g. from
x - A: 123 B: 456 C: 678
I'd like to get
c(A:, 123 , B: , 456 , C: , 678)
but
strsplit(x, [A-Z]+:)
gives me
c(, 123 , 456 , 678)
Any ideas?
Thanks,
Hadley
--
http://had.co.nz/
Try this:
library(gsubfn)
x - A: 123 B: 456 C: 678
strapply(x, [^ :]+[ :]|[^ :]+$)
[[1]]
[1] A: 123 B: 456 C: 678
and check out the gsubfn home page at:
http://gsubfn.googlecode.com
On Sat, Jun 14, 2008 at 1:35 AM, hadley wickham [EMAIL PROTECTED] wrote:
Hi all,
Does anyone have
Try:
sapply(strsplit(TEXT, ';'), '[', 1)
On Fri, Apr 11, 2008 at 8:12 AM, Dennis Fisher [EMAIL PROTECTED] wrote:
Colleagues,
I have some text:
TEXT- c(a, bb;ccc, ;e;ff)
I want to retrieve the portion of each element before the first
semicolon. I can split each
/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: Dennis Fisher [EMAIL PROTECTED]
To: r-help@r-project.org
Sent: Friday, April 11, 2008 1:12 PM
Subject: [R] strsplit and sapply
Colleagues
Colleagues,
I have some text:
TEXT- c(a, bb;ccc, ;e;ff)
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]]
Here is a command I wrote to get the part of the email address before
the @ sign. It works, but I don't know why. The variable called
email is a vector of email addresses (not yet in character form, so
that is why I need as character).
names(Score) - sapply(email,function(x)
my understanding is that this behavior is known (the help file
mentions something along these lines in the example).
i'd use something like:
theText - a,,b,
theText - gsub(\\,$, , , theText)
and then use strsplit() on theText
b
On Dec 3, 2007, at 6:22 PM, dankelley wrote:
I have a
I have a comma-separated data file in which trailing commas sometimes occur.
I am using strsplit to extract the data from this file, and it seems great
except in cases with trailing comma characters.
The example below illustrates. What I'd like is to get a fourth element in
the answer, being
dankelley wrote:
I have a comma-separated data file in which trailing commas sometimes occur.
I am using strsplit to extract the data from this file, and it seems great
except in cases with trailing comma characters.
The example below illustrates. What I'd like is to get a fourth element in
Try appending another comma:
strsplit(paste(a,,b,, ,, sep = ), ,)
On Dec 3, 2007 6:22 PM, dankelley [EMAIL PROTECTED] wrote:
I have a comma-separated data file in which trailing commas sometimes occur.
I am using strsplit to extract the data from this file, and it seems great
except in
This works perfectly. Thanks!
Peter Dalgaard wrote:
Hmm, I don't think strsplit can do that. However:
scan(textConnection(a,,b,), sep=,, what=)
Read 4 items
[1] a b
--
O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of
On 22 October 2007 at 00:43, Edna Bell wrote:
| 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
|
|
|
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
Try
strsplit(vv,$,fixed=TRUE)
--- Edna Bell [EMAIL PROTECTED] wrote:
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]
On Mon, 22 Oct 2007, Edna Bell wrote:
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
89 matches
Mail list logo