Practical Predictive Analytics
上QQ阅读APP看书,第一时间看更新

Code description

Here is a line by line description of the code which you have just run:

  • install.packages("stargazer"): The line will install the package to the default package directory on your machine. If you will be rerunning this code again, you can comment out this line, since the package will have already be installed in your R repository.
  • library(stargazer): Installing a package does not make the package automatically available. You need to run a library (or require()) function in order to actually load the stargazer package.
  • stargazer(lm_output, , type="text"): This line will take the output object lm_output, that was created in the first script, condense the output, and write it out to the console in a simpler, more readable format. There are many other options in the stargazer library, which will format the output as HTML, or Latex.

Please refer to the reference manual at https://cran.r-project.org/web/packages/stargazer/index.html for more information.

The reformatted results will appear in the R Console. As you can see, the output written to the console is much cleaner and easier to read.