# Re: [R] "& not meaningful for factors

From: jim holtman <jholtman_at_gmail.com>
Date: Wed, 04 Jun 2008 08:18:37 -0400

What exactly are you trying to do? In the first case you are making a logical comparison and that is legal for "&". In the second you are trying to do a logical operation ("&") between two factors and that operation is not defined. This is what the error message is saying.

Also you first attempt is probably missing a comma:

node1 <- data.trt[data.trt\$stage=="1B" & data.trt\$diameter=="=< 4", ]

On Wed, Jun 4, 2008 at 8:10 AM, Philip Twumasi-Ankrah < nana_kwadwo_derkyi_at_yahoo.com> wrote:

> I am trying to define groupings from levels of factor variables and this
> the warning message that R give
>
> "& not meaningful for factors".
>
> The nature of my task is this. I have a variable stage which has the levels
> (1B, 2A, 2B) - these are the AJCC TNM stages of cancer, and another variable
> diameter with factor levels ("=< 4", "4 - 6.5, > 6.5; limit values are
> exclusive).
>
> I am trying to define series of groupings based on these variables and
> others like them.
>
> My first attempts were;
>
> 1. node1 <- data.trt[data.trt\$stage=="1B" & data.trt\$diameter=="=< 4"]
> 2. data.trt\$stage[data.trt\$stage=="1B"]&
> data.trt\$diameter[data.trt\$diameter=="=< 4"]
>
> The second attempt was purely a fishing exercise.
>
> R gave me the waring message:
>
> Warning message:
> In Ops.factor(data.trt\$stage[data.trt\$stage == "1B"],
> data.trt\$diameter[data.trt\$diameter == :
> & not meaningful for factors
>
>
> My question is how do I get round this and by implication is there an
> alternative way of defining a logical operation applicable to factors.
>
> Thanks already for the help.
>
> Philip
>
>
> A Smile costs Nothing
>
> But Rewards Everything
>
> Happiness is not perfected until it is shared
> -Jane Porter
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

```--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help