Re: [R] Substring error

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu 25 Jan 2007 - 10:29:05 GMT

On Thu, 25 Jan 2007, talepanda wrote:

> It occurs why start or stop could not be converted into integer of
> length > 0 by using as.interger().
>
> More presicely,
> if( !isInteger(sa) || !isInteger(so) || k == 0 || l == 0 ) # c code
> where sa is start, so is stop, k is length(start), l is length(stop)
>
> For example:
>
> substr("orz",character(0),0)
> substr("orz",numeric(0),0)
> substr("orz",logical(0),0)
> substr("orz",integer(0),0)
> substr("orz",NULL,0)
>
> produce the error because of k==0
>
>
> But there seems to be another case which I don't know.

That's essentially it. The first two conditions are merely protection against someone calling the .Internal directly.

In particular, there is no documentation as to what happens if start or stop is NA, a case I don't think is handled correctly.

>
>
> On 1/25/07, Shubha Vishwanath Karanth <shubhak@ambaresearch.com> wrote:
>> 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]]
>>
>> ______________________________________________
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Jan 25 21:34:18 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 11:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.