rapporter / pander Goto Github PK
View Code? Open in Web Editor NEWAn R Pandoc Writer: Convert arbitrary R objects into markdown
Home Page: http://rapporter.github.io/pander/
License: Open Software License 3.0
An R Pandoc Writer: Convert arbitrary R objects into markdown
Home Page: http://rapporter.github.io/pander/
License: Open Software License 3.0
Gergely,
I'm trying to run your "minimal example" at https://github.com/Rapporter/pander/blob/master/inst/examples/minimal.brew but keep on getting odd errors:
> Pandoc.brew("C:/Users/mbacou/Google Drive/2010-HH/_global_codes/R/pander_test.md", output=tempfile(), convert="pdf")
Error: Error: `Using a reserved word as variable: `plot``
I tried the next example at https://github.com/Rapporter/pander/blob/master/inst/examples/short-code-long-report.brew
> Pandoc.brew("C:/Users/mbacou/Google Drive/2010-HH/_global_codes/R/pander_test.md", output=tempfile(), convert="pdf")
Error: Error (`Using a reserved word as variable: `plot``) in your BRCODEs: `
for (v in names(mtcars)) {
`, `
}
`, `
for (v in names(mtcars)[-6]) {
` and `
}
`
Am I missing something obvious?
I'm running this through Eclipse StatET, here is my session info:
sessionInfo()
# R version 2.15.1 (2012-06-22)
# Platform: x86_64-pc-mingw32/x64 (64-bit)
#
# locale:
# [1] LC_COLLATE=English_United States.1252
# [2] LC_CTYPE=English_United States.1252
# [3] LC_MONETARY=English_United States.1252
# [4] LC_NUMERIC=C
# [5] LC_TIME=English_United States.1252
#
# attached base packages:
# [1] stats graphics utils datasets grDevices methods base
#
# other attached packages:
# [1] devtools_0.8 lattice_0.20-10 ggplot2_0.9.2.1 pander_0.3
# [5] codetools_0.2-8 knitr_0.8 rj_1.1.0-4
#
# loaded via a namespace (and not attached):
# [1] colorspace_1.2-0 dichromat_1.2-4 digest_0.6.0 evaluate_0.4.2
# [5] formatR_0.6 grid_2.15.1 gtable_0.1.1 httr_0.2
# [9] labeling_0.1 MASS_7.3-22 memoise_0.1 munsell_0.4
# [13] parallel_2.15.1 plyr_1.7.1 proto_0.3-9.2 RColorBrewer_1.0-5
# [17] RCurl_1.95-3 reshape2_1.2.1 rj.gd_1.1.0-1 scales_0.2.2
# [21] stringr_0.6.1 tools_2.15.1 whisker_0.1
[sas@analytic ~]$ R --vanilla
R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Platform: i686-redhat-linux-gnu (32-bit)
library(pander)
Pandoc.brew(system.file('examples/graphs.brew', package='pander'))
Error: Error (argument 1 matches multiple formal arguments
) in your BRCODEs: `
df <- mtcars[, c('hp', 'wt')]
df$factor <- sample(c('Foo', 'Bar', 'Foo bar'), size = nrow(df), replace = TRUE)
df$factor2 <- sample(c('Foo', 'Bar', 'Foo bar'), size = nrow(df), replace = TRUE)
df$time <- 1:nrow(df)
require(ggplot2, quietly = TRUE)
require(lattice, quietly = TRUE)
eO <- evalsOptions()
pO <- panderOptions()
evalsOptions('graph.unify', TRUE)
evalsOptions('cache', FALSE)
,
panderOptions('graph.fontfamily', "Comic Sans MS")
panderOptions('graph.fontsize', 18)
panderOptions('graph.fontcolor', 'blue')
panderOptions('graph.grid.color', 'blue')
panderOptions('graph.axis.angle', 3)
panderOptions('graph.boxes', T)
panderOptions('graph.legend.position', 'top')
panderOptions('graph.colors', rainbow(5))
panderOptions('graph.grid', FALSE)
panderOptions('graph.symbol', 22)
` and `
As stated in the title, calling Pandoc.convert() to convert a markdown file into a docx file no longer drags the figures into the docx.
I noticed that the behavior of pander()
and pandoc.table()
are different. I like the way pander()
does to keep the trailing zeros. Is it possible to let pandoc.table()
do the same thing?
panderOptions("digits", 4)
a<-c(7, 7.1, 7.233)
pander(a)
7, 7.100 and 7.233pandoc.table(a)
7 7.1 7.233
I use pandoc.table
to generate tables in markdown for publication. Using pandoc, it works great. However, the table in the markdown file itself looks horrible. Using style = "rmarkdown"
on GitHub doesn't work because you're adding extra :
in the delimiter line. Deleting those works fine. Maybe add another style?
Running the function Pandoc.brew
with a file with the next code
<% library(etable) %>
<%
n <- 1000
ddff <- data.frame(escala=factor(sample(1:5, n, replace=TRUE), labels=c("1.- Escala 1", "2.- Escala 2", "3.- Escala 3", "4.- Escala 4", "5.- Escala 5")), sexo=factor(rbinom(n, 1, 0.4), labels=c("Men", "Women")), n=rep(1, n))
%>
<%
tabla <- tabular.ade(x_var="escala", rows=c("escala", "ALL"), rnames=c("Escala que me invento"), data=ddff, FUN=n_cell, type="colpctn", nonames=FALSE)
%>
<%= tabla %>
Results the following message
Internal pander
error: arguments imply differing number of rows: 2, 3
while running: tabla
Please report the issue with a reproducible example to help developers fix this ASAP.
Hello,
For such a table:
> dd
Test Transfo.
1 ANTIGENIC ACTIVITY PE-PILA BY ELISA none
2 PH none
3 PROTEIN CONTENT BY HPLC none
4 PROTEIN CONTENT RECOVERY BY HPLC_1 log10
5 PURITY PE-PILA BY SDS-PAGE none
6 RATIO PE-PILA POPULATIONS BY HPLC log10
pandoc.table()
returns this message because some names are too long:
> pandoc.table(dd, style="rmarkdown")
Error in table.expand(x, t.width, justify, sep.col) :
Pandoc does not support newlines in simple or Rmarkdown table format!
However I don't ask to put newlines in the table, so why does the function defines some newlines ? I can get a perfect rendering (after html converting) of the table I want as follows:
> dd$Test <- gsub(" ", "XxxX", dd$Test)
> tabl <- pandoc.table.return(dd, style="rmarkdown")
> cat(gsub("XxxX", " ", tabl))
| Test | Transfo. |
|:---------------------------------------------------:|:----------:|
| ANTIGENIC ACTIVITY PE-PILA BY ELISA | none |
| PH | none |
| PROTEIN CONTENT BY HPLC | none |
| PROTEIN CONTENT RECOVERY BY HPLC_1 | log10 |
| PURITY PE-PILA BY SDS-PAGE | none |
| RATIO PE-PILA POPULATIONS BY HPLC | log10 |
test <- glm(speed ~ dist,family="poisson",data=cars)
pander(test)
pander(test,covariate.labels = c("Some label"))
Two last lines produce an identical result, which is not as intended.
I would like to use pander in combination with packages that generate complex tables like etable
or tables
, but when tables have categories with nested rows, pander formats empty row headers writing ****. The following is a simple example.
Thanks for your great package.
library(pander)
text <- '# A table with etable
+ pander
<% require(etable) %>
Number of cases is <%= (n <- 100) %>
<% ddff <- data.frame(fila=sample(LETTERS[1:5], n, replace=TRUE), columna=sample(LETTERS[6:8], n, replace=TRUE), capa=sample(LETTERS[9:10], n, replace=TRUE)) %>
<% tabla <- tabular.ade(x_vars="fila", rows=c("fila", "capa"), cols="columna", FUN=n_cell, data=ddff, nonames=FALSE) %>
Here is the table with ****
<%= tabla %>'
Pandoc.brew(text=text)
Current implementation of pander does not allow to specify width of table columns.
I understand underlying pandoc's implementation lacks support of advanced width formatting, but there is a workaround.
Pandoc in html mode sets widths of generated columns relative to the widths of columns in markdown formatting.
That means, if pander artificialy extends column width it would influence the width of generated html.
I see three possible options:
I did try using different flavours of Pandoc.brew, however all they result in very obscure error messages.
It would be grateful if you could update documentation with some official way of reusing *.brew files.
@eipi10 has just reported a strange issue on OSX: https://gist.github.com/daroczig/5238455#comment-805311
That's a bug in [Pandoc.brew#L134
]
If using something like:
pandoc.table(head(iris)[, 1:3], style="rmarkdown", justify=c("left", "right", "center"))
to create a table, I get the following error:
Error in match.arg(justify) :
'arg' should be one of “left”, “right”, “centre”, “none”
It's easy enough for me to then go back and change the spelling, but it might be convenient to also have both US and UK ways of spelling "center/centre" be valid.
Current implementation of emphasize.*
hardcodes formatting functions pandoc.emphasis.*
I have two usecases:
Could you please clarify what is the way to solve these tasks?
It's immense how lucid ideas pop up when you write the documentation. =)
Anyway... it came to me that p.wrap
should act differently depending on the class of an object. For characters it's fine to have something, like and this, but for numeric vectors, it may be: 3
, 4
, 5
or even something nuts like {3, 4, 5}
. Notice that I got rid of copula in numeric vectors. Just think about it... not all the objects should get the same output. So yeah... hello useMethod
.
Seems that b, n, p & s are a little shy...
pander(as.data.frame(letters), plain.ascii=TRUE)
a
c
d
e
f
g
h
i
j
k
l
m
o
q
r
t
u
v
w
x
y
z
Current javascript collects all the headings to the TOC, while it makes sense keeping only important ones (say up to h2).
I would suggest either option to limit (hX level, e.g. h1, h2, h3, ...) and/or rely on pandocs # My header {.exclude_from_toc} feature
Here's code to reproduce the issue.
I expect no header row.
pandoc.table(t(
data.frame(
"Date"="2013/05/12"
, "Issue"="Headerless tables"
, "Expected result"="No header"
, "Actual result"="empty header row")
)
)
---------------------------------------
--------------------- -----------------
**Date** 2013/05/12
**Issue** Headerless tables
**Expected.result** No header
**Actual.result** empty header row
---------------------------------------
pandoc.table(data.frame(a="\\1",b="23"))
results in
-------
a b
--- ---
\1 23
-------
The issue might come from that nchar("\\1", type = 'width')
is 2, but format("\\1", width = 3)
gives "\\1"
and not "\\1 "
. (?format says "... Thus the width is as displayed by print(quote = FALSE) and not as displayed by cat.")
BTW superb library, congrats and thanks! Greetings from Csepel, Laci Szakacs
It would be nice having the option to interpret \n in multiline tables. For now as far as I know \n is ignored and "table.split.cells" is fully in charge. Just throwing that idea out there, but maybe to avoid conflicts, this could be activated if and only if table.split.cells = Inf ?
I posted this question on SO and received a suggestion to raise the issue here.
I am using pander to print nicer looking tables via RStudio, knitr, pander, pandoc, Word. I have a two-page table, to which I would like to add a Spanish caption:
set.caption("Límites izquierdo y derecho para las diferentes variables")
pander(LimitesUnivariado, include.rownames=FALSE)
This almost works, but my caption states:
Table: Límites izquierdo y derecho para las diferentes variables (continued below)
I can't find find the way to change the Table
and continued below
to their Spanish equivalents. Is it possible to do it?
Thank you!
When generating output with a call to p
trailing zeros are removed from the exponent for numbers in scientific notation if the base contains non-zero decimals. For example, p(1.2e-60)
produces "_1.2e-6_"
but p(1e-60)
and p(1.0e-60)
are fine.
I first noticed this in the pandoc output from an htest object because the p-vale was way off. So this more than a little inconvenient.
Edit: Looking at the code it seems that this regex in the body of function p
is responsible for the problem (line 79 in helpers.R):
sub('(?:(\\..*[^0])0+|\\.0+)$', '\\1',x)
Something like sub('(?:(\\.[^e]*[^0])0+|\\.0+)$', '\\1',x)
might fix the issue but it is unclear to me whether this is needed at all after the call to format
.
This option is important because professional tables typically do not have bolded or italicized row labels (e.g., see examples in Ch. 3 of Chicago Manual of Style). The response on StackOverflow suggests a workaround, but pander will be more useful if it can produce professional tables without a workaround.
I have been playing with examples using pander
and am curious how to make nice html tables with pander
in an Rmd file with knitr.
So here's a comparison:
https://dl.dropboxusercontent.com/u/61803503/Errors/pander_comparison.txt
(sorry don't know how to post and Rmd MWE without it being parsed by github)
and the output:
https://dl.dropboxusercontent.com/u/61803503/Errors/test.html
The xtable
approach produces a nice html table but the pander
approach does not (using knit HTML button in RStudio). However if I convert the md file to a pdf using pandoc
the result is beautiful. This tells me I just don't know how to use pander
correctly. Can I not use knitr
to produce the html table with pander
?
When using pandoc.table on a data.frame, values within the produced table are not matching the complete string (such as on character vectors produced from formatted numbers)
Example:
> table_okay <- data.frame(numbers = c("1,001", "1,002"))
> pandoc.table(table_okay)
---------
numbers
---------
1,001
1,002
---------
> table_with_error <- data.frame(numbers = c("1,000", "1,001"))
> pandoc.table(table_with_error )
---------
numbers
---------
1
1,001
---------
<!--head
meta:
title: ANOVA Template
author: Aleksandar Blagotić, Dániel Nagy
description: An ANOVA report with table of descriptives, diagnostic tests and ANOVA-specific
statistics.
email: ~
packages: nortest
example:
- 'rapport("anova", ius2008, resp = "leisure", fac = "gender") # one-way'
- 'rapport("anova", ius2008, resp = "leisure", fac = c("gender", "partner")) # two-way'
inputs:
- name: test
label: test
description: test
class: character
value: ~
required: yes
standalone: yes
- name: noneed
label: test
description: test
class: numeric
length:
min: 1
max: 2
required: yes
standalone: no
head-->
<% for (i in 1:3) { %>
<%= signif <- paste(pander.return(lapply(1:i, function(i) paste0(p(c(rownames(test)[i])), ' (', round(test[i], 3), ')'))), collapse = '\n')
signif
%>
<% } %>
Current brew errors are hard to impossible to debug.
It might throw Error: Error (duplicate 'row.names' are not allowed
) in your BRCODEs: and you are alone with the error.
The best I figured out is a binary search over the template source (just exclude half of the text) to identify the bad statement.
options(error=traceback), error=browser, error=recover do not help (I did not manage to figure out the failing line of code).
Nicer error reporting would be very handy.
It would be neat if there were an additional option to place the caption above the table instead of beneath it. Using such an option might look like this:
df <- data.frame(letters, 1:26)
pandoc.table(df, caption = "Example Table", caption.placement = "top")
I suggest the name caption.placement because the package xtable has an option named that, but I suppose it could be called anything.
It would be very useful for me to have the option to generate plain-ascii tables without any markup characters such as 'nbsp;' or '**', so that the output can be copied and pasted from the R console to a plain text editor. Many thanks for the great work!
It would be grate to export the report in a single HTML page, as it would enable easy sharing the results (e.g. email).
Quick&dirty attempt (pandoc --self-contained ...
) revealed the following issues:
url('...?dsfsdf')
are not properly parsed by pandoc (error is "file not found"). Should be an issue to pandoc, but a WA from pander would be great<a href="...">
to base64. I suggest put <img style="display:none">
and enhance it via javascript. That should work properly with linked and data-uri encoded images.For long codes constant image capturing can take a significant amount of time:
library(microbenchmark)
op <- microbenchmark(
W = {
t <- tempfile()
png(t,type = "windows")
dev.off()
},
C = {
t <- tempfile()
png(t,type = "cairo")
dev.off()
},
times = 1000
)
print(op)
Unit: microseconds
expr min lq median uq max neval
W 8181.580 8721.048 9036.386 9462.962 84413.318 1000
C 193.341 220.158 337.354 389.993 1481.179 1000
I suggest a global option to allow/suppress image capturing, that can be overwritten locally with a function call in a code chunk.
# Setting up the table (no pun intended)
library(pander)
colors <- rep(c("blue","orange","red","yellow"),times=c(2,13,108,1780))
col.table <- table(colors)
# First see what happens with default settings (all fine here)
pander(col.table, justify="center")
##
## ------------------------------
## blue orange red yellow
## ------ -------- ----- --------
## 2 13 108 1780
## ------------------------------
# Now with style="simple"
# Only column names (and the largest number) are centered
pander(col.table, style="simple", justify="center")
##
##
## blue orange red yellow
## ------ -------- ----- --------
## 2 13 108 1780
# Same applies with right justifying
pander(col.table, style="simple", justify="right")
##
##
## blue orange red yellow
## ------ -------- ----- --------
## 2 13 108 1780
# Now with transposed tables
# Only the row names respond to the justify argument
col.table.transposed <- t(t(col.table))
pander(col.table.transposed, style="simple", justify="center")
##
## ------------ ----
## **blue** 2
## **orange** 13
## **red** 108
## **yellow** 1780
## ------------ ----
pander(col.table.transposed, style="simple", justify="right")
##
## ------------ ----
## **blue** 2
## **orange** 13
## **red** 108
## **yellow** 1780
## ------------ ----
# compare with
pander(col.table.transposed, justify="right")
##
## ------------ ----
## **blue** 2
##
## **orange** 13
##
## **red** 108
##
## **yellow** 1780
## ------------ ----
Your version of pander
is awesome and has helped me a lot with my reports, but there is a problem with the argument emphasize.strong.cols
in the pandoc.table()
function and I thought I should bring it to your attention. If the user specifies more than one column, the result is that the columns are mixed up. Example below:
library(devtools)
install_github('pander', 'Rapporter')
ex <- matrix(1:100, 10, 10)
pandoc.table(ex, style='rmarkdown')
pandoc.table(ex, style='rmarkdown', emphasize.strong.cols = 2:3)
You can see the differences between the two tables below:
1 | 11 | 21 | 31 | 41 | 51 | 61 | 71 | 81 | 91 |
2 | 12 | 22 | 32 | 42 | 52 | 62 | 72 | 82 | 92 |
3 | 13 | 23 | 33 | 43 | 53 | 63 | 73 | 83 | 93 |
4 | 14 | 24 | 34 | 44 | 54 | 64 | 74 | 84 | 94 |
5 | 15 | 25 | 35 | 45 | 55 | 65 | 75 | 85 | 95 |
6 | 16 | 26 | 36 | 46 | 56 | 66 | 76 | 86 | 96 |
7 | 17 | 27 | 37 | 47 | 57 | 67 | 77 | 87 | 97 |
8 | 18 | 28 | 38 | 48 | 58 | 68 | 78 | 88 | 98 |
9 | 19 | 29 | 39 | 49 | 59 | 69 | 79 | 89 | 99 |
10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 |
1 | 11 | 16 | 31 | 41 | 51 | 61 | 71 | 81 | 91 |
2 | 21 | 26 | 32 | 42 | 52 | 62 | 72 | 82 | 92 |
3 | 12 | 17 | 33 | 43 | 53 | 63 | 73 | 83 | 93 |
4 | 22 | 27 | 34 | 44 | 54 | 64 | 74 | 84 | 94 |
5 | 13 | 18 | 35 | 45 | 55 | 65 | 75 | 85 | 95 |
6 | 23 | 28 | 36 | 46 | 56 | 66 | 76 | 86 | 96 |
7 | 14 | 19 | 37 | 47 | 57 | 67 | 77 | 87 | 97 |
8 | 24 | 29 | 38 | 48 | 58 | 68 | 78 | 88 | 98 |
9 | 15 | 20 | 39 | 49 | 59 | 69 | 79 | 89 | 99 |
10 | 25 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 |
This is also observed with data frames.
I'm working with tables in pander
and I noted that cell alignment does not always work properly. I'm copying an example with a character table. The cells in the html file are always left-aligned. Maybe the problem is in the column widths in the markdown file.
Regards.
library(pander)
panderOptions("table.split.table", Inf)
text <- '<% library(etable)
data(Titanic)
titanic <- as.data.frame(Titanic)
tabla <- tabular.ade(x_vars="Class", w="Freq", rows=c("Sex", "Age"), cols=c("Class", "Survived"), FUN=n_cell, data=titanic, nonames=FALSE)
%>
Table without any options
<%= tabla %>
Table right justified
<%= pandoc.table.return(tabla, justify="right") %>
Table left justified
<%= pandoc.table.return(tabla, justify="left") %>
Table center justified
<%= pandoc.table.return(tabla, justify="center") %>'
Pandoc.brew(text=text)
Pandoc.brew(text=text, output="borrame.md", convert="html")
A recent question on SO showed a rather dummy error in pander
:
> pander(summary(lm(mtcars$wt~mtcars$hp)))
Error in sink(file) : sink stack is full
In addition: There were 20 warnings (use warnings() to see them)
This is because we call summary
for lm
objects. Probably we should also have a summary.lm
pander method, and we should call that inside of pander.lm
... @RomanTsegelskyi: can you please fix this or should I?
@stevepowell99 opened this issue at Rapporter/rapport#71
pandoc.table(table(1))
This can occur e.g. if looping through variables and you don't know in advance that the table is going to have length 1. Would be nice if pandoc.table could cope with this.
Thanks.
I think I've stumbled upon a bug. I have a glm model which is contains multiple dependent variables, something like this
model <- glm(dependent ~ independent1 + independent2 + independent3 + independent4 + independent5 + independent6 + independent7,data=mydata,family=binomial)
Now, when I pander(model)
it, the table with model coefficients is printed twice. It is not wrapped or broken in two parts - the very same table gets printed twice. And the culprit is the default caption. When it is too long so that there is not enough space to print it under the first table, the second table is rendered and the caption continues there. Simply supplying an argument with shorter caption fixes the problem. Surprisingly, supplying a long custom caption did not produce the outcome.
Hi I can't work out how to use *apply (or loops) with pander.
I would like to be able to produce bunches of tables and figures using lapply (or loops) and have the captions set correctly.
<%=
lapply(mtcars,function(c){
set.caption('qwer')
print(histogram(c))
})
%>
sets the caption correctly but gives only one histogram.
changing print(histogram(c)) to print(table(c)) gives me all the tables I expected but does not set the caption.
A very nice feature of pander is the ability to render models (lm, etc) in Markdown syntax. This allows a very seamless integration of model presentation, as MD tables are easily converted both to PDF and docx with pandoc. The stargazer package (which can be seen as a similar tool for the purpose of model rendering) produces LaTeX code, and thus works (automatically) only for conversion to PDF. So far so good.
One of the features from stargazer I really miss in pandoc is the ability to specify variable names in the model output. Pander simply takes the original variable names, and this approach fails when variables are factors. R assigns them names like "gendermale" or "educationlowe". These need to be edited by hand before being put in a publishable text.
It is not difficult by all means, just edit the tables manually before the publication, and that's it. However it would be better if these reader-friendly names could be specified programmatically.
Well, that and thanks for pander, it is really a pleasure working with it.
At https://github.com/daroczig/pander in examples of "Brew to Pandoc" section pdf/odt/docx files contain R source code but not tables/images.
If run e.g. "Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'), output = tempfile(), convert = 'odt')" than all is ok, and output odt file contains figures and tables.
I can't systematically reproduce the bug, but sometimes happen.
Command (with the latest olympics-webapp.brew file):
library(pander)
setwd('e:/rapport')
u <- "ATH-220"
Pandoc.brew("olympics-webapp_renew2.brew", output='e:/rapport/tmp/test', convert='html')
Pandoc.brew("olympics-webapp_renew2.brew", output='e:/rapport/tmp/test', convert='html')
Pandoc.brew("olympics-webapp_renew2.brew", output='e:/rapport/tmp/test', convert='html')
By the first run always OK, but sometimes the second or the third run kill the database and show a false results.
(When I tested it now, it made the bug, but after a restart i couldn't reproduce...)
I noticed that p
method has a flow:
> panderOptions("p.sep", "")
> panderOptions("p.wrap", "")
> panderOptions("p.copula", "")
> Pandoc.brew(text = "<%= LETTERS %>")
ABCDEFGHIJKLMNOPQRSTUVWXY Z
This calls for a simple fix. I'll file a pull request soon.
First, great job @daroczig!
Okay, the issue title sucks, but here's the deal, in a nutshell: you may want to provide optional argument, like fields
and put some default there, like fields = c("statistic", "parameter", "p.value")
. That way one can include/exclude columns from table. Of course, this applies to pretty much all objects... Just a thought, may be silly... =)
I see in helper.R
that Pander
uses nchar()
to determine column width by number of characters in the string. That is not suitable for cjk characters, I'd suggest using nchar(x, type='type')
to handle CJK characters.
Hi,
I am trying to get a neat output from an lm object. Here goes:
x <- rnorm(100,mean=4)
y <- log(x)
model <- lm(y~x)
panderOptions('round')
[1] Inf
pander(model)
--------------------------------------------------------------
Estimate Std. Error t value Pr(>|t|)
----------------- ---------- ------------ --------- ----------
**(Intercept)** 0.174 0.03739 4.653 1.025e-05
**x** 0.2909 0.008972 32.42 3.452e-54
--------------------------------------------------------------
Table: Fitting linear model: y ~ x
panderOptions('round',2)
pander(model)
--------------------------------------------------------------
Estimate Std. Error t value Pr(>|t|)
----------------- ---------- ------------ --------- ----------
**(Intercept)** 0.17 0.04 4.653 1.025e-05
**x** 0.29 0.01 32.42 3.452e-54
--------------------------------------------------------------
Table: Fitting linear model: y ~ x
So, only estimates and standard errors are rounded, and not the t- and p-values. Is this is a bug or am I missing some new option to control this? Thanks!
However weird it may seem at first, it may be useful to make Pander.brew
behave like (return output identical to) genuine brew
method. Two ideas came to my mind:
brew
output when p.sep
, p.wrap
and p.copula
are set to NULL
or empty string (related to issue #23)I(<object>)
to suppress processingPandoc.brew(text="<%=0%>",output="x.md")
creates
/plots/x.md-1.png
(what is a white square).
Cheers, L (Ps: Meet you in a week!:)
pandoc.list
doesn't return the properly indented list if a sub-list has only one element.
Suppose I want to make the following list:
I'd do
pandoc.list(list('one', list('two')))
However this returns
* one
* list("two")
If however the sublist has more than one element, everything works fine:
pandoc.list(list('one', list('two', 'three')))
* one
* two
* three
I believe the error is in this line of pandoc.list.return
.
if (length(elements[[i]]) == 1) { # <--- THIS LINE
paste0(paste(rep(' ', indent.level * 4), collapse = ''), marker[i-i.lag], elements[i])
} else {
...
Note that in the case of the element list('two')
, elements[i]
has length 1 but the string representation of elements[i]
is list("two")
.
If you change it to:
if (length(elements[[i]]) == 1 && !is.list(elements[[i]])) {
then all works as expected.
I am unsure if this breaks some other use case, though.
knitr
uses PHP Markdown Extra style tables, which means that pandoc.table()
doesn't seem to work well with knitr
. Adding a new style to markdown table might make it easier to use pander
in a knitr
workflow (see, for example Stack Overflow: Programmatically creating Markdown tables in R with KnitR.
PS: I haven't tried to implement the left/right/center alignment yet, but I'm happy to start working on it if needed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.