PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, August 13, 2022

[FIXED] How to reduce the regression output in markdown

 August 13, 2022     markdown, output, r, regression     No comments   

Issue

I want to show a regression output in markdown but it contains a lot of character variables which result in a lot of independent variables. Is there any way to only show in the summary the first 5 variables? The summary function in combination with the options(max.print=80) does not provide the solution I want.


Solution

You can use tidy() function from broom package

library(broom)
library(magrittr)

lm(mpg ~ ., data = mtcars) %>% tidy() %>% head(n = 5)

#> # A tibble: 5 × 5
#>   term        estimate std.error statistic p.value
#>   <chr>          <dbl>     <dbl>     <dbl>   <dbl>
#> 1 (Intercept)  12.3      18.7        0.657   0.518
#> 2 cyl          -0.111     1.05      -0.107   0.916
#> 3 disp          0.0133    0.0179     0.747   0.463
#> 4 hp           -0.0215    0.0218    -0.987   0.335
#> 5 drat          0.787     1.64       0.481   0.635

Created on 2022-07-08 by the reprex package (v2.0.1)



Answered By - shafee
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing