Re: [Rd] Argument recycling in substring()

From: Hadley Wickham <hadley_at_rice.edu>
Date: Fri, 04 Jun 2010 06:15:16 -0500

> 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)) :
>    invalid substring argument(s)
>
> But I don't get one here:
>
>  > substring(character(0), first=1:2, last=3L)
>  character(0)
>
> which is unexpected.

If you want a set of string functions that strive to be simple and consistent you might want to look at the stringr package. And since it's a new package, I'm very keen to remove any inconsistencies.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 04 Jun 2010 - 11:21:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jun 2010 - 16:00:58 GMT.

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

list of date sections of archive