Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect parsing of rownames #3

Open
r2evans opened this issue Jan 15, 2015 · 1 comment
Open

incorrect parsing of rownames #3

r2evans opened this issue Jan 15, 2015 · 1 comment

Comments

@r2evans
Copy link

r2evans commented Jan 15, 2015

When running ess-R-dv-ctable on R's ubiquitous dataset mtcars, there are two things wrong:

|  |                   mpg|cyl| disp| hp|drat|   wt| qsec|vs am|gear|carb|
+--+----------------------+---+-----+---+----+-----+-----+-----+----+----+
|Ma|zda RX4           21.0|  6|160.0|110|3.90|2.620|16.46| 0  1|   4|   4|
|Ma|zda RX4 Wag       21.0|  6|160.0|110|3.90|2.875|17.02| 0  1|   4|   4|
|Da|tsun 710          22.8|  4|108.0| 93|3.85|2.320|18.61| 1  1|   4|   1|
...
  1. The rownames are incorrectly assumed to be 2 characters (because there are <100 rows, perhaps?). This is directly affecting the first column. This is repeated if we remove the first column (mtcars <- mtcars[,-1]) and its first column cyl is now affected. If we remove the rownames (rownames(mtcars) <- NULL), the problem goes away.
  2. The two columns vs and am do not have a separator pipe | between them.
@r2evans
Copy link
Author

r2evans commented Jan 15, 2015

Perhaps instead of doing this manually in elisp, would it be acceptable to use knitr::kable?

R> knitr::kable(mtcars)


|                    |  mpg| cyl|  disp|  hp| drat|    wt|  qsec| vs| am| gear| carb|
|:-------------------|----:|---:|-----:|---:|----:|-----:|-----:|--:|--:|----:|----:|
|Mazda RX4           | 21.0|   6| 160.0| 110| 3.90| 2.620| 16.46|  0|  1|    4|    4|
|Mazda RX4 Wag       | 21.0|   6| 160.0| 110| 3.90| 2.875| 17.02|  0|  1|    4|    4|
|Datsun 710          | 22.8|   4| 108.0|  93| 3.85| 2.320| 18.61|  1|  1|    4|    1|

The extra rows padding the top are likely for knitr's Rmarkdown ties and can easily be filtered out.

Is it wrong to expect the user will have knitr installed? (If they've installed RStudio -- even if they don't use it regularly -- they already have knitr.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant