

   substr {base}                                R Documentation

   EExxttrraacctt SSuubbssttrriinnggss ffrroomm aa CChhaarraacctteerr VVeeccttoorr

   DDeessccrriippttiioonn::

        Extract substrings from a character vector returning a
        vector whose elements contain the substring starting
        with the character at position `start' up to the char-
        acter at position `stop'.

   UUssaaggee::

        substr(x, start, stop)
        substring(text, first, last = 1000000)

   DDeettaaiillss::

        If `start' is larger than the string length then `NA'
        is returned.  If `stop' is longer than `start' an error
        is signalled.

        `substring' is compatible with S, with `first' and
        `last' instead of `start' and `stop'.  For vector argu-
        ments, it expands the arguments cyclically.

   SSeeee AAllssoo::

        `strsplit', `paste', `nchar'.

   EExxaammpplleess::

        substr("abcdef",2,4)
        print(ss <- substring("abcdef",1:6,1:6))
        all(  ss == strsplit ("abcdef",NULL)[[1]])# strsplit is more efficient..

        substr(rep("abcdef",4),1:4,4:5)
        x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech")
        all(substr(x, 2, 5) == substring(x, 2, 5)) #> TRUE
        substr(x, 2, 5)
        substring(x, 2, 4:6)

