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

add method for summary.lm ($coef) #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

bquast
Copy link

@bquast bquast commented Feb 2, 2016

There is still a slight problem in that it prints

Pr(>|t|)

as:

Pr(¿—t—)

in LaTeX documents

@bquast bquast mentioned this pull request Feb 3, 2016
@bquast
Copy link
Author

bquast commented Feb 3, 2016

library(printr)
lm(speed ~ dist, data=cars)
            Estimate   Std. Error    t value   Pr(>|t|)

(Intercept) 8.2839056 0.8743845 9.473985 0
dist 0.1655676 0.0174945 9.463990 0

Note that it's GFM that doesn't render this table well, it works fine in R

@yihui
Copy link
Owner

yihui commented Feb 4, 2016

For the LaTeX problem, did you have \usepackage[T1]{fontenc} in the preamble?

#' @export
knit_print.lm = function(x, options, ...) {
res = paste(c(
'', '', kable(summary(x)$coef, options$render.args$kable$format, ...)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest a different form of printing, e.g. print out the regression equation, instead of the identical output as the summary.lm method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good idea, I wasn't sure what to do with the summary one but that makes sense. I'll update this now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think about this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean lm gives the equation of the form dist = ? + ? speed (instead of the R call), and summary.lm gives the coefficient matrix.

@bquast
Copy link
Author

bquast commented Feb 4, 2016

I'm using LyX which I'm quite sure does this when rendering using pdflatex, it also occurs when using LuaTeX.

This may be related, when I produce a kable in an ERT in standard text it always works fine, but the if the first number is negative (i.e. coefficient of the intercept) and I embed it in a table float, in fails to render.

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

Successfully merging this pull request may close these issues.

2 participants