Displaying 20 results from an estimated 5000 matches similar to: "perl expression question"
2008 Aug 06
2
matching problem
I have a matching problem that I cant solve.
mystring = "xxx{XX}yy{YYY}zzz{Z}" where "x","X","y","Y","z","Z" basiclly can
be anything, letters, digits etc. I'm only interested in the content within
each "{}".
I am close but not really there yet.
library(gsubfn)
strapply(mystring,"\\{[^\\}]+",, perl=F)
2006 Oct 18
1
how to manipulate counts matrix?
Hi List,
I've got a count matrix like this:
[-11.9,-11] (-11,-10.2] (-10.2,-9.3] (-9.3,-8.44]
[-11.9,-10.6] 0 0 0 0
(-10.6,-9.3] 0 0 0 0
(-9.3,-8.01] 0 0 0 0
(-8.01,-6.73] 0 0 0 0
I want to
2006 Nov 29
1
Extract some character from a character vector of length 1
the content of th character vector (of length 1) is as follows:
a <- "something2 ....pat1 name1 pat2 something2....pat1 name2
pat2....pat1 name3 pat2 "
I would like to extract the character bewteen pat1 and pat2. That's to
say, I would like to get a vecter of c("name1", "name2","name3").
What I did is use strsplit() twise. But I wonder if there
2008 Jul 18
3
How to cut data elements included in a text line
Hello,
assume I have an "unstructured" text line from a connection. Unfortunately,
it is in string format:
R> x
[1] "\talpha0\t-0.638\t0.4043\t0.4043\t-2.215\t-0.5765\t-0.137\t501\t2000"
How can I extract the data included in this string object "x" in order to
get the elements for the parameter vector called "alpha0", i.e.
-0.638 0.4043 0.0467
2008 Oct 28
1
gsubfn, strapply, REGEX Problem
Hi all,
I swear this used to work:
library(gsubfn)
strapply("S(AC,P)TVDK(8)EELVQK(8), ".[(].{1,2}[)]|.")[[1]]
But somewhere along the update path it stopped ... now giving me this
Error in base::gsub(pattern, rs, x, ...) :
invalid backreference 2 in regular expression
Can't figure it out. What am I doing wrong?
Thanks for any hints, Joh
2023 Apr 12
1
Split String in regex while Keeping Delimiter
On Wed, 12 Apr 2023 08:29:50 +0000
Emily Bakker <emilybakker at outlook.com> wrote:
> 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 ++?)
>
2007 Sep 25
5
extracting data using strings as delimiters
Dear List,
I have an ascii text file with data I'd like to extract. Example:
Year Built: 1873 Gross Building Area: 578 sq ft
Total Rooms: 6 Living Area: 578 sq ft
There is a lot of data I'd like to ignore in each record, so I'm
hoping there is a way to use strings as delimiters to get the data I
want (e.g. tell R to take data between "Built:" and "Gross" -
2009 Mar 03
4
regular expression question
can someone show me how to use a regular expression to break the string
at the bottom up into its three components :
(-0.791,-0.263]
(-38,-1.24]
(0.96,2.43]
I tried to use strplit because of my regexpitis ( it's not curable. i've
been to many doctors all over NYC. they tell me there's no cure ) but
it doesn't work because there also dots inside the brackets. Thanks.
2007 Aug 23
2
Splitting strings
I'm having a Thursday morning mental block, any suggestions on the following
would be most appreciated...
I have (as an example)
surgery = c("d48", "d67", "dnc37", "a75", "d10", "a78", "d31",
"d55", "d1")
before each number part the possibilities are c("a", "d",
2008 Nov 02
5
R newbie: how to replace string/regular expression
Hello;
I am a R newbie and would like to know correct and efficient method for
doing string replacement.
I have a large data set, where I want to replace character "M", "b",
and "K" (currency in Million, Billion and K) to millions. That is
209.7B with (209.7 * 10e6) and 100.00K with (100.00 *1/100)
and etc..
d <- c("120.0M", "11.01m",
2010 Mar 15
2
tcltk and R
I have had some comments on sqldf regarding its dependence on tcltk
such as the second last sentence on this blog post:
http://translate.google.com/translate?hl=en&sl=zh-CN&u=http://www.wentrue.net/blog/%3Fp%3D453&prev=http://blogsearch.google.com/blogsearch%3Fhl%3Den%26ie%3DUTF-8%26q%3Dsqldf%26lr%3D%26sa%3DN%26start%3D10
sqldf does not directly use tcltk but it does use strapply in
2010 Oct 13
5
Regular expression to find value between brackets
Hi,
this should be an easy one, but I can't figure it out.
I have a vector of tests, with their units between brackets (if they have
units).
eg tests <- c("pH", "Assay (%)", "Impurity A(%)", "content (mg/ml)")
Now I would like to hava a function where I use a test as input, and which
returns the units
like:
f <- function (x) sub("\\)",
2008 Aug 01
2
Extract Element of String with R's Regex
Hi,
I have this string, in which I want to extract some of it's element:
> x <- "Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35"
yielding this array
[1] "211952_at" "RANBP5" "2"
In Perl we would do it this way:
__BEGIN__
my @needed =();
my $str = "Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL=
-963.669
2010 Jul 02
3
Good Package(s) for String and URL processing?
Are there packages that allow improved String and URL processing?
E.g. extract parts of a URLs such as sub-domains, top-level domain,
protocols (e.g. https, http, ftp), file type based on endings, check
if a URL is valid or not, etc...
I am currently only using split and paste. Are there better and more
efficient ways to handle strings e.g. finding sub-strings or to do
pattern matching?
What
2008 Aug 09
2
levels values of cut()
Dear list,
I have the following example, from which I am hoping to retrieve
numeric values of the factor levels (that is, without the brackets):
>
> x <- seq(1, 15, length=100)
> y <- sin(x)
>
> my.cuts <- cut(which(abs(y) < 1e-1), 3)
> levels(my.cuts)
hist() does not suit me for this, as it does not necessarily respect
the number of breaks.
getAnywhere
2010 Aug 26
5
Quick GREP challenge
> grep("f[0-9]+=", "f1=5,f22=3,", value = T)
[1] "f1=5,f22=3,"
How do I make the line output c("f1", "f22") instead? (Actually, c(1,22)
would be even better).
Thank you.
--
View this message in context: http://r.789695.n4.nabble.com/Quick-GREP-challenge-tp2339486p2339486.html
Sent from the R help mailing list archive at Nabble.com.
2008 Jan 23
1
Package Building and Name Space
Hello,
I just don't get this and would appreciate if someone could write a line or
two: I'm trying to build this package and it stops installing after I add
the following to the NAMESPACES file:
>importFrom(gsubfn,strapply)
The error during the package test is:
Error in MyPackage::MyFunction :
package 'MyPackage' has no name space and is not on the search path
Calls:
2009 Jul 08
5
R regular expression to extract words with the query string.
Hi,
Is there a way in R to get the string which matches the expression, where
the expression is a substring of the parent string.
Lets say, I have $i <- "transcript:ENST0000112334 pid:ENSP000012345"
What I need is the string "pid:ENSP000012345" from $i using the query
"ENSP".
Appreciate your comments.
Praveen Surendran
School of Medicine and
2008 Oct 15
4
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 the first two instances of [0-9]. Note that
there may be only one digit
2009 Sep 20
1
perl functions in R enviroment
dear all,
I am trying to implement some perl scripting in R to improve the performance
of some scripts.
I found RSPerl library, but it seems to be quite tricky to import variables.
this is a simple example.
is there any simpler way to do it?
furthermore is there any other available resource to interface the two
language? RSPerl seems to be no longer supported
and when I load it R complains about