Displaying 20 results from an estimated 1518 matches for "substring".
2019 Feb 20
2
Bug: time complexity of substring is quadratic as string size and number of substrings increases
Hi all, (and especially hi to Tomas Kalibera who accepted my patch sent
yesterday)
I believe that I have found another bug, this time in the substring
function. The use case that I am concerned with is when there is a single
(character scalar) text/subject, and many substrings to extract. For example
substring("AAAA", 1:4, 1:4)
or more generally,
N=1000
substring(paste(rep("A", N), collapse=""), 1:N, 1:N)
The pro...
2019 Feb 22
1
Bug: time complexity of substring is quadratic as string size and number of substrings increases
On 2/20/19 7:55 PM, Toby Hocking wrote:
> Update: I have observed that stringi::stri_sub is linear time complexity,
> and it computes the same thing as base::substring. figure
> https://github.com/tdhock/namedCapture-article/blob/master/figure-substring-bug.png
> source:
> https://github.com/tdhock/namedCapture-article/blob/master/figure-substring-bug.R
>
> To me this is a clear indication of a bug in substring, but again it would
> be nice to h...
2020 Oct 05
2
isc-dhcp dynamic update problem
...8,
""
,
substring
(
hardware,
1,...
2019 Feb 20
0
Bug: time complexity of substring is quadratic as string size and number of substrings increases
Update: I have observed that stringi::stri_sub is linear time complexity,
and it computes the same thing as base::substring. figure
https://github.com/tdhock/namedCapture-article/blob/master/figure-substring-bug.png
source:
https://github.com/tdhock/namedCapture-article/blob/master/figure-substring-bug.R
To me this is a clear indication of a bug in substring, but again it would
be nice to have some feedback/confirmatio...
2010 Jun 04
2
Argument recycling in substring()
Hi,
According to its man page substring() "expands (its) arguments
cyclically to the length of the longest _provided_ none are of
zero length".
So, as expected, I get an error here:
> substring("abcd", first=2L, last=integer(0))
Error in substring("abcd", first = 2L, last = integer(0)) :
inva...
2018 Jan 21
3
substr gives empty output
Dear all,
I have a string, let's say "testing", and I would like to extract in
sequence each letter (character) from it. But when I use substr() I only
properly get the first character, the rest is empty (""). What am I getting
wrong?
For example, I have this code:
>>>
x <- "testing"
k <- nchar(x)
for (i in 1:k) {
y <- substr(x, i, 1)
2009 Dec 19
3
integer(0) and NA do not equal FALSE
Hi,
A noobie question: I'm simply trying to run a conditional statement that
evaluates if a substring is found within a larger string. I find that if it
IS found, my function returns TRUE (great!), but if not, the condition does
not evaluate to FALSE.
ex):
if( grep("hi", "hop", fixed = TRUE) )
print('yes, your substring is in your string')
else print('no, yo...
2018 Jan 22
2
substr gives empty output
In
y <- substr(x, i, 1)
your third integer needs to be the location not the number of digits, so change it to
y <- substr(x, i, i)
and you should get what you want.
Cheers,
Tim
> Date: Sun, 21 Jan 2018 10:50:31 -0500
> From: Ek Esawi <esawiek at gmail.com>
> To: Luigi Marongiu <marongiu.luigi at gmail.com>, r-help at r-project.org
> Subject: Re: [R] substr
2009 Dec 01
1
explanation for left-side behaviour
Hi there,
I'm pretty sure that it's written down somewhere but I cannot find it so
far.
The little example shows different approaches to replace a substring.
Only the last one works. I think it has something to do with the fact
that "substr" is used on the left side. Can anybody refer to an
explanation for this behaviour?
Thanks a lot in advance!
Antje
values <- factor(c(rep("abc",3), rep("bcd",3), rep("cde...
2013 Jan 30
2
substring from behind
Hello together,
i have a question for "substring".
I know i can filter a number like this one:
bill$No<-substring(bill$Customer,2,4)
in this case i get the 2nd, 3rd and 4th number of my Customer ID.
But how can i do this, if i want the 2nd, 3rd and 4th number of a column.
Like this one.
I have: Mercedes_02352
Audi_03555
and now i want t...
2007 Jan 25
1
Substring error
Hi,
Do anybody know when and why the below error we get?
Error in substr(x, as.integer(start), as.integer(stop)) :
invalid substring argument(s) in substr()
Thanks in advance,
Shubha
[[alternative HTML version deleted]]
2011 Apr 11
1
Getting many substrings but only loading the original string one time.
Hi All,
I'm looking for a way to get many substrings from a longer string and
then stitch them together. But, since the longer string is really, really
long (like 250 MB long), I don't want to do this in a loop and load and
re-load the longer string many times. Does anybody have an idea?
Maybe I could pass in two vectors (the first would have...
2013 Dec 13
1
substring() and propagation of names
Hi,
In R < 3.0.0, we used to get:
> substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
A B A B A
"bcdef" "2345" "bcd" "23" "b"
But in R >= 3.0.0, we get:
> substring(c(A="abcdefghij", B="123456789"...
2007 May 10
3
Getting the last day of the month.
Hi,
Given a date, how do I get the last date of that month? I have
data in the form YYYYMM, that I've read as a date using
> x$Date <-
as.Date(ISOdate(substr(x$YearEnd,1,4),substr(x$YearEnd,5,6),1))
But this gives the first day of the month. To get the last day of the
month, I tried
> as.Date(as.yearmon(x$Date,frac=0))
But I don't get the last day of the month here. (Tried
1999 Aug 03
3
RW 0.64.2 substring() string truncation?
Hi,
(First, apology for my earlier incorrectly addressed "subscribe"
post.)
Can somebody tell me what exactly is going on below. Basically, I am
running into some kind of "string truncation" problem when I try
to get a substring starting past the 8192nd character (see sample
session below). There doesn't appear to be any problem creating the
string, and nchar() reports the correct size as constructed.
# Start of R session:
> tmp <- paste(rep("1",8192),sep="",collapse="")
> nch...
2006 Aug 14
4
Test for string in string
Hi,
Is there an easy way to test if a substring exists in a string?
I''m using this check:
if mystring.index(substring) > 0
but it doesn''t seem to be working....
Thanks!
--
Posted via http://www.ruby-forum.com/.
2010 Jul 19
1
Help with replacing a substring in a string
Dear R Users,
I am trying to replace a substring in a string with something else.
For example:
if we have "abc.degg.hijk"
I would like to replace all the "." with a SPACE to become
"abc degg hijk"
I have tried the replace.substring.wild function in the Hmisc package but get this error:
> replace.substring.wild(...
2009 Aug 25
1
Filling in empty arrays/lists from using "paste" function
...bb,ee=TA2.ee,gg=TA2.gg,tt=TA2.tt,uu=TA2.uu*)* etc for TA3~TA5.
Although these generate the output I desire, I would like to use a single
statement for producing 5 different arrays (instead of 5 different
statements)
I have tried the following codes, however the last statement (paste("T",
substring(i,3,4), sep="") <- c(bb ......) gives error message reading "Error
in paste("T", substring(i, 3, 4), sep = "") <- c(bb = paste(paste("T",
: target of assignment expands to non-language object"
for (i in unique(a$id))
for (j in unique(a$pro)...
2001 Sep 07
2
Why does substr<- truncate and not replace...
... when the replacement string is shorter than the portion of the
string to be replaced?
The documentation to substr (in R 1.3.1) gives me:
If the portion to be replaced is longer than the replacement
string, then only the portion the length of the string is
replaced.
And so I try:
R> x <- "abcdef"
R> substr(x,2,3) <- "xy" #ok
R> x
[1]
2001 Sep 07
2
Why does substr<- truncate and not replace...
... when the replacement string is shorter than the portion of the
string to be replaced?
The documentation to substr (in R 1.3.1) gives me:
If the portion to be replaced is longer than the replacement
string, then only the portion the length of the string is
replaced.
And so I try:
R> x <- "abcdef"
R> substr(x,2,3) <- "xy" #ok
R> x
[1]