dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
512 stars 77 forks source link

Error in ctable function: $ operator is invalid for atomic vectors #58

Closed Ranlod closed 5 years ago

Ranlod commented 5 years ago

When I use the ctable function with the pipe operator %$% from the package magrittr an error occurs: Error: $ operator is invalid for atomic vectors

library(summarytools)
library(magrittr)

tobacco %$% ctable(smoker, diseased)

Traceback

  1. na.omit(c(parse_info_y$var_names, deparse(dnn[[2]]))) at ctable.R#194
  2. ctable(smoker, diseased)
  3. eval(substitute(expr), data, enclos = parent.frame())
  4. eval(substitute(expr), data, enclos = parent.frame())
  5. with.default(., ctable(smoker, diseased))
  6. with(., ctable(smoker, diseased))
  7. function_list[k]
  8. withVisible(function_list[k])
  9. freduce(value, _function_list)
  10. _fseq(_lhs)
  11. eval(quote(_fseq(_lhs)), env, env)
  12. eval(quote(_fseq(_lhs)), env, env)
  13. withVisible(eval(quote(_fseq(_lhs)), env, env))
  14. tobacco %$% ctable(smoker, diseased)

Error appears in na.omit function in line 194, ctable.R file.

y_name  <- na.omit(c(parse_info_y$var_names, deparse(dnn[[2]])))[1]

Many thanks.

dcomtois commented 5 years ago

I will look into that... In the meantime, is using with() a viable option for you?

dcomtois commented 5 years ago

Could you pls try again with the dev-current version and let me know if everything is okay? (Data frame name & label if present, variable names accurate in the headings section)

To install: devtools::install_github("dcomtois/summarytools", ref = "dev-current")

Thx

Ranlod commented 5 years ago

When i used the command devtools::install_github("dcomtois/summarytools", ref = "dev-current")

The code tobacco %$% ctable(smoker, diseased) was successfully executed. Thanks!