dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ctable not working with numeric variables?

flh3 opened this issue · comments

Hello-- ctable used to work with numeric variables (see below) but I've started getting errors. If I convert this to a factor, it works but this used to work even with numeric variables (like the table function). Is there another way around this?
Thank you!

> data(mtcars)
> ctable(mtcars$am, mtcars$cyl) #used to work
Error in `rownames<-`(x, value) : 
  attempt to set 'rownames' on an object with no dimensions
> 
> mtcars$am <- factor(mtcars$am)
> mtcars$cyl <- factor(mtcars$cyl)
> ctable(mtcars$am, mtcars$cyl) #this was how it looked even when not a factor
Cross-Tabulation, Row Proportions  
am * cyl  
Data Frame: mtcars  

------- ----- ------------ ----------- ------------ -------------
          cyl            4           6            8         Total
     am                                                          
      0          3 (15.8%)   4 (21.1%)   12 (63.2%)   19 (100.0%)
      1          8 (61.5%)   3 (23.1%)    2 (15.4%)   13 (100.0%)
  Total         11 (34.4%)   7 (21.9%)   14 (43.8%)   32 (100.0%)
------- ----- ------------ ----------- ------------ -------------

Hi, pls install the github version, which includes a patch for this. An update to CRAN is coming soon!