Skip to content
Prev 350213 / 398506 Next

Problem with col

On Mon, Apr 20, 2015 at 12:56 PM, Sonia Amin <soniaamin5 at gmail.com> wrote:
A factor is one of the basic types of data in R, and in statistics
generally, eg M/F or red/white/blue - a predetermined set of
categories that may or may not have an order.

More relevantly, if there's something wrong in your data, a stray
letter or quote mark for instance, that column is no longer numeric,
and R will read it as a factor by default, otherwise as character.

str(data)

which is NOT the same as just typing data, will show you the classes
of your columns, among other things.
If you just look at data directly, you'll see what look like numbers,
perhaps, but according to R one or more columns are not actually
numbers. That's why you need str(data).

Your problem looks like a lack of basic understanding of how R works.
Here are a couple of sources that might help you get started:
http://www.burns-stat.com/documents/tutorials/impatient-r/
http://cyclismo.org/tutorial/R/


For more help, you should provide at least the output of str(data) to
the list, and ideally a reproducible example. Here are some
suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Sarah