[R] / Operator not meaningful for factors

From: Vivek Satsangi <vivek.satsangi_at_gmail.com>
Date: Sun 15 Jan 2006 - 22:06:22 EST


Folks,
I have a very basic question. The solution eludes me perhaps because of my own lack of creativity. I am not attaching a fully reproducible session because the issue may well be becuase of the way the data file is, and the data file is large (and I don't know whether I can legally distribute it). If people can suggest things that might be wrong in my data or the way that I am reading it, I would be most grateful.

I get the following error message in the session quoted at the end of this email:
/ not meaningful for factors in: Ops.factor(BookValuePS, Price)

As you can see in that some session, I check that the two vectors being divided are numeric. I also check that the divisor is not 0 at any index. I also believe that this is not because of the NA's in the data. My question is, what are other "problems" that can cause the / operator to not be meaningful?

I did try some simple examples to try to get the same error. However, I am not sure how to put the same NA's that one gets from read.table() into a vector:
> a <- c(1, 2, 3, NA);
> a
[1] 1 2 3 NA
> b <- c( 1, 2, 3, 4);
> c <- b / a;
> b
[1] 1 2 3 4
> a <- c(1, 2, 3, );
> c <- b/a;
Warning message:
longer object length

        is not a multiple of shorter object length in: b/a

--
-- Vivek Satsangi
Student, Rochester, NY USA

______________________________________________
R-help@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
Received on Sun Jan 15 22:20:24 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:04 EST