Re: [R] selecting characters from a line of text

From: Vladimir Eremeev <wl2776_at_gmail.com>
Date: Tue, 12 Jun 2007 01:03:23 -0700 (PDT)

Tim Holland 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?
>

Use substr() or substring() to select characters from a a text string, nchar() will give you its length,
scan() can also help in reading data from text files, grep() can be used for search and selecting character strings in an array, having certain patterns.

If your files are formatted in some way, consider read.table(), read.csv(), read.fwf() and friends.

You should also read the "Data import/export" manual from the R documentation.
Its pdf version was, probably, installed on your hard drive with R, and html is here:
http://cran.r-project.org/doc/manuals/R-data.html pdf version is also here:
http://cran.r-project.org/doc/manuals/R-data.pdf

-- 
View this message in context: http://www.nabble.com/selecting-characters-from-a-line-of-text-tf3904063.html#a11074650
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_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
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 12 Jun 2007 - 08:08:27 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 Tue 12 Jun 2007 - 08:31:52 GMT.

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