Contingency Table for Correspondence Analysis


I am using RStudio Cloud to conduct Correspondence Analysis (CA). When I import the .csv dataset which is already in a general contingency table format, R is placing an X in the first column and is referring to it as a factor. When I try to run CA, I get:

Error in sum(N) : invalid 'type' (character) of argument

which I suspect is because I have this unnecessary factor column.

Here is quick shot of what it looks like now and what I need it to look like in RStudio:

Thank you for your time!


If you are using base R function read.csv it has a parameter stringsAsFactors which in most cases will be TRUE. So there are two ways you can change this behavior:

  1. In your call to read.csv set stringsAsFactors = FALSE.
  2. Or you can use readr::read_csv that doesn't have this behavior. Since you are using RStudio Cloud I'm fairly certain it should be available already for you.