Re: [R] factors

From: Gabor Grothendieck <>
Date: Thu, 05 May 2011 18:45:47 -0400

On Thu, May 5, 2011 at 6:28 PM, J <> wrote:
> Hi, I'm requesting you don't berate me for asking this question:
> I clearly don't have the gist of factors.
> I have two dataframes, A and B.
> Each of them has a column containing strings (they're labels).
> I want to, one-by-one in a loop, compare the particular string in an entry from dataframe A to an entry in B, to see if they're the same.
> The problem, when posing the question:
> searchID1 <- A[['label']][i]
> possMatch1 <- B[['label']][j]
> searchID1 == possMatch1
> I get the error:
> Error in Ops.factor(searchID1, possMatch1) :
>  level sets of factors are different
> I presume this is because the set of possible values in the 'labels' columns, respectively in A and B, differ.  In my case, I'm not interested in this at all; I just want to compare individual entries from the two dataframes in a pair-wise fashion.
> Can I strip the "factors" associated with the entries?  Is there a better way?

Assuming you read them in using read.table, use read.table(...whatever..., = TRUE) and then it will read them as character strings rather than factors.

Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 05 May 2011 - 22:50:18 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 Thu 05 May 2011 - 23:00:05 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive