[R] Problems with table

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Feb 3 22:05:07 CET 2003

Patricia Maforte dos Santos wrote:
> Hi,
> I'm having difficulties in the manipulation of the function table.
> Necessary to have access its elements and I am not obtaining. For example,
> if I have a data.frame with name "df" and make:
> t < - data.frame(table(df))

Dou you really want to generate a data.frame from that table?
BTW: Assigning is done by "<-", not "< -" ...

> and later trying to make a comparison of the type t[1,1 ] < 0.1, generates
> an error of the type:
> [1] NA
> Warning message:
> "<" not meaningful for factors in: Ops.factor(t[1, 1], 0.1)

Because t[1,1] is an element of a vector of class "factor" (due to the
use of data.frame()).
BTW: t() is a very basic function in R. Thus it's generally a bad idea
to call another object "t", although it works at least in this case.

> How can I resolve this?

I guess you want something like 
 table(df)[1,1] < 0.1
don't you?

Uwe Ligges

> Thanks,
> ----------------------------------
> Patrícia Maforte dos Santos
> Centro de Informatica
> Universidade Federal de Pernambuco
> Recife/PE - Brasil
> ----------------------------------

More information about the R-help mailing list