R-alpha: substring (again)

Robert Gentleman (rgentlem@stat.auckland.ac.nz)
Wed, 10 Apr 1996 09:07:10 +1200


Date: Wed, 10 Apr 1996 09:07:10 +1200
From: Robert Gentleman <rgentlem@stat.auckland.ac.nz>
Message-Id: <199604092107.JAA07144@stat.auckland.ac.nz>
To: R-testers@stat.math.ethz.ch
Subject: R-alpha: substring (again)

It seems that I managed to get the wrong first argument
so you really want

substring := function(text,first,last=1000000)
{
        storage.mode(text) <- "character"
        n <- max(length(text), length(first), length(last))
        text <- rep(text, length = n)
        first <- rep(first, length = n)
        last <- rep(last, length = n)
        substr(text, first, last)
}

robert
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-