[R] Regular Expressions in Column Headings
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Mar 9 15:24:33 CET 2011
On Wed, Mar 9, 2011 at 8:52 AM, Matthew DeAngelis <ronin78 at gmail.com> wrote:
> Hi all,
>
> I am hoping that someone can help me with a problem I am having with column
> headings. I have read a table into R using read.table: the rows are
> documents, and the columns are counts of regular expression matches (so that
> the column heading is the given regular expression). My problem is that
> read.table seems to be trying to interpret the regular expressions, or has
> trouble with the special characters, so that the column headings are not
> coming out correctly. For example, a column headed with: \bV\.?A\.?T\.?
> will come out as X.bV...A...T... This would not be a problem, since the
> regular expressions are still readable, except that I have a number of other
> tables that I will need to intersect with these column headings. In some of
> those tables, the regular expressions are data, and they are coming in
> correctly (although R seems to be doubling "\"s, which is fine so long as it
> does this consistently).
>
> I have also tried importing the column names as a vector and specifying that
> vector explicitly using col.names, but R still transforms the provided names
> as above. Is it possible to force R to read in regular expressions
> completely literally, with no interpretation? Alternately, can I force R to
> interpret the column headings in the same way that it interprets data (i.e.
> adding the extra slash), so that I can match on these values?
>
See the read.table check.names argument.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list