[R] sub('^','var',1:3) produces unexpected results

From: David Forrest <drf5n_at_maplepark.com>
Date: Wed 23 Mar 2005 - 08:02:20 EST


Hi,

According to help(sub), the ^ should match the zero-length string at the beginning of a string:

sub('^','var',1:3) # "1" "2" "3"
sub('$','var',1:3) # "1var" "2var" "3var"

# This generates what I expected from the first case: sub('^.','var',11:13) # "var1" "var2" "var3"

Dave

-- 
 Dr. David Forrest
 drf@vims.edu                                    (804)684-7900w
 drf5n@maplepark.com                             (804)642-0662h
                                   http://maplepark.com/~drf5n/

______________________________________________
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
Received on Wed Mar 23 08:06:02 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:53 EST