Maybe substring() is what you're looking for? Some examples:

> substring("textstring",1,5)
[1] "texts"
> substring("textstring",3)
[1] "xtstring"
> substring("textstring",3,nchar("textstring"))
[1] "xtstring"


--- Tim Holland <[EMAIL PROTECTED]> wrote:

> Is there a way in R to select certain characters from a line of text?  I
> have some data that is presently in a large number of text files, and I
> would like to be able to select elements of each text file (elements are
> always on the same line, in the same position) and organize them into a
> table.  Is there a tool to select text in this way in R?  What I am looking
> for would be somewhat similar to the left() and right() functions in Excel.
> I have looked at the parse() and scan() functions, but don't think they can
> do what I want (although I could be wrong).
> Thank you,
> Tim
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> [email protected] 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.
>

______________________________________________
[email protected] 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.

Reply via email to