ess-R-data-view.el
ess-R-data-view.el copied to clipboard
incorrect parsing of rownames
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|
...
- 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 columncyl
is now affected. If we remove the rownames (rownames(mtcars) <- NULL
), the problem goes away. - The two columns
vs
andam
do not have a separator pipe|
between them.
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
.)