Displaying 20 results from an estimated 10000 matches similar to: "strcapture enhancement"
2016 Sep 21
2
error handling in strcapture
Michael, thanks for looking at my first issue with utils::strcapture.
Another issue is how it deals with lines that don't match the pattern.
Currently it gives an error
> strcapture("(.+) (.+)", c("One 1", "noSpaceInLine", "Three 3"),
proto=list(Name="", Number=0))
Error in strcapture("(.+) (.+)", c("One 1",
2016 Sep 21
2
error handling in strcapture
If there are any matches then strcapture can see if the pattern has the
same number of capture expressions as the prototype has columns and give an
error if not. That seems appropriate.
If there are no matches, then there is no easy way to see if the prototype
is compatible with the pattern, so should strcapture just assume the best
and fill in the prototype with NA's?
Should there be
2016 Oct 04
2
error handling in strcapture
I noticed a problem in the strcapture from R-devel (2016-09-27 r71386),
when the text contains a missing value and perl=TRUE.
{
# NA in text input should map to row of NA's in output, without
warning
r9p <- strcapture(perl = TRUE, "(.).* ([[:digit:]]+)", c("One 1", NA,
"Fifty 50"), data.frame(Initial=factor(), Number=numeric()))
e9p <-
2016 Oct 04
1
error handling in strcapture
It is also not catching the cases where the number of capture expressions
does not match the number of entries in proto. I think all of the
following should give an error about the mismatch.
> strcapture("(.)(.)", c("ab", "cde", "fgh", "ij", "lm"),
proto=list(A="",B="",C=""))
A B C
1 a b cd
2 d
2016 Sep 21
0
error handling in strcapture
The new behavior is that it yields NAs when the pattern does not match
(like strptime) and for empty captures in a matching pattern it yields
the empty string, which is consistent with regmatches().
Michael
On Wed, Sep 21, 2016 at 2:21 PM, William Dunlap <wdunlap at tibco.com> wrote:
> If there are any matches then strcapture can see if the pattern has the same
> number of capture
2016 Oct 04
0
error handling in strcapture
Hi Bill,
This is a bug in regexec() and I will commit a fix.
Thanks for the report,
Michael
On Tue, Oct 4, 2016 at 1:40 PM, William Dunlap <wdunlap at tibco.com> wrote:
> I noticed a problem in the strcapture from R-devel (2016-09-27 r71386), when
> the text contains a missing value and perl=TRUE.
>
> {
> # NA in text input should map to row of NA's in output,
2016 Sep 21
0
error handling in strcapture
Hi Bill,
Thanks, another good suggestion. strcapture() now returns NAs for
non-matches. It's nice to have someone kicking the tires on that
function.
Michael
On Wed, Sep 21, 2016 at 12:11 PM, William Dunlap via R-devel
<r-devel at r-project.org> wrote:
> Michael, thanks for looking at my first issue with utils::strcapture.
>
> Another issue is how it deals with lines that
2019 Aug 15
2
Feature request: non-dropping regmatches/strextract
I do think keeping the default behavior is desirable for backwards compatibility; my suggestion is not to change default behavior but to add an optional argument that allows a different behavior. Although this can be implemented in a user-defined function, retaining empty matches facilitates programmatic use, and seems to be something that should be available in base R. It is available, for
2009 Apr 13
3
toupper does not work in sub + regex
Hi, I don't know what I am doing wrong to the toupper does not seem
working in sub + regex. The following returns 's' not the upper class
'S' as I expect:
sub("q_([a-z])[a-zA-Z]*",toupper('\\1'),"q_sviRaw")
Can someone tell me where I did wrong?
Thanks,
Richard
[[alternative HTML version deleted]]
2019 Aug 15
1
Feature request: non-dropping regmatches/strextract
Using a non-capturing group, "(?:...)" instead of "(...)", simplifies my
example a bit
> x <- c("Groucho <groucho at marx.com>", "<chico at marx.com>", "Harpo")
> strcapture("([[:alpha:]]+)?(?: *<([[:alpha:]. ]+@[[:alpha:]. ]+)>)?", x,
proto=data.frame(Name=character(), Address=character(),
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.
2009 Apr 13
1
should sub(perl=TRUE) also handle \E in replacement, to complement \U and \L?
Currently sub(perl=TRUE) allows you to specify \U and \L
in the replacement argument so that the rest of the subpatterns
in the line (the \\<digit> things) will be converted to upper
or lower case, respectively. perl also also has a \E operator
to end these case conversions for the rest of the subpatterns
(so they retain whatever case they had in the original text).
For symmetry's sake
2024 Jan 29
1
strcapture performance when perl = TRUE
I wanted to raise the possibility of improving strcapture performance in
cases where perl = TRUE. I believe we can do this in a non-breaking way
by calling regexpr instead of regexec (conditionally when perl = TRUE).
To illustrate this I've put together a 'proof of concept' function called
strcapture2 that utilises output from regexpr directly (following a very
nice substring approach
2019 Aug 15
0
Feature request: non-dropping regmatches/strextract
I don't care much for regmatches and haven't tried strextract, but I think
replacing the character(0) by NA_character_ is almost always inappropriate
if the match information comes from gregexpr.
I think strcapture() does a pretty good job of what I think you are trying
to do. Perhaps adding an argument to map no match to NA instead of ""
would give you just what you wanted.
2011 Apr 29
4
For loop and sqldf
Hi list,
Can anyone tell my why the following does not work? Thanks a lot! Your help
is very much appreciated.
DF = data.frame(read.table(textConnection(" B C D E F G
8025 1995 0 4 1 2
8025 1997 1 1 3 4
8026 1995 0 7 0 0
8026 1996 1 2 3 0
8026 1997 1 2 3 1
8026 1998 6 0 0 4
8026 1999 3 7 0 3
8027 1997 1 2 3 9
8027 1998 1 2 3 1
8027 1999
2010 Dec 26
4
Parsing a Simple Chemical Formula
Hello R Folks...
I've been looking around the 'net and I see many complex solutions in
various languages to this question, but I have a pretty simple need
(and I'm not much good at regex). I want to use a chemical formula as
a function argument. The formula would be in "Hill order" which is to
list C, then H, then all other elements in alphabetical order. My
2006 May 10
3
NumbersToWords
= numbersToWords - convert your integers and floats to english or
japaneese words,or translate it into american currency
- This plugin was created from a solution to the ruby quiz (english
numbers) by Matthew D Moss. I modified the code to work as a rails
plugin and added the to_dollars method.
- the to_dollars method will work with integers and floats
- the to_english and to_japaneese methods
2019 Sep 02
2
Feature request: non-dropping regmatches/strextract
I think that's a good reason for not including this in regmatches; you're right, its name is somewhat suggestive of yielding matches. Also, that sounds like a great design for strcapture with an atomic prototype.
Best,
CG
2005 Oct 08
2
color for points
Hi,
I have the following code to
randomly generate the
points:
csr <-function(n=60){
x=runif(n)
y=runif(n)
f=cbind(x,y)
}
plot(csr())
I wonder how to code to make the first twenty points to be BLUE; second twenty points to be RED; the last twenty points to be GREEN?
Thanks,
Sam
---------------------------------
[[alternative HTML version deleted]]
2005 Dec 31
2
numeric_spell plugin
I''ve created a plugin that lets you spell out numbers (under one
thousand, in English, for now).
Examples:
>> 23.spell
=> "twenty-three"
>> 23.spell :noun => ''person''
=> "twenty-three people"
>> (23.14).spell_currency
=> "twenty-three dollars and fourteen cents"
>>