[R] level sets of factors are different
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Jan 7 13:42:12 CET 2006
The message is really explicit.
You are trying to compare the equality of two factors with different level
sets. Such factors are not comparable (and this is discussed on ?factor).
You didn't give a reproducible example, and you have not told us what you
are trying to do, so all we can do is repeat R's report that what you
actually did is not sensible.
On Sat, 7 Jan 2006, Richard van Wingerden wrote:
> Hi,
>
> I have two data frames A en B.
> I want to filter B with values of A
>
> data_frame_b
> names <- colnames(data_frame_b[1:1, ])
>
> filtera <- data.frame(data_frame_a[1:1])
This is bit strange. data_frame_a[1:1] is data_frame_a[1] and is a
single-column data-frame. I think you might just as well use
filtera <- data_frame_a[[1]]
which is (probably) a factor. You then seem to want to extract values
equal to its first element, so maybe you actually wanted
columnX == as.character(data_frame_a[1,1]) ?
>
> print(nrow(filtera))
>
> if (nrow(filtera)>0){
>
> filtered_frame_b <- subset(data_frame_b, ColumnX == filtera[1, 1], names)
> }
> The results are:
>
> [1] 124
> Error in Ops.factor(ColumnX, filtera[1, 1]) :
> level sets of factors are different
>
>
> What is wrong??
>
> Richard
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list