> On Oct 16, 2018, at 12:33 PM, Neslin, Scott A. 
> <scott.a.nes...@tuck.dartmouth.edu> wrote:
> 
> R-Help:
> 
> We are working with your GLM R package.  The Summary(Model) now gets printed 
> by the program as one object and we want to put the coefficient columns into 
> Excel.  We took an initial stab at this by counting the number of characters 
> occupied by each column.  But we have now learned that the number of 
> characters in a column depends on the length of the variable names, so is not 
> a constant number (e.g., 54 characters to a line).
> 
> We therefore ask, is it possible for us to get the Summary(Model) column by 
> column, i.e., a separate object for each column?  That way we could assemble 
> an Excel table easily rather than having to count the number of characters.
> 
> Is this possible for us to do by ourselves?  Or could you modify the package 
> in some way?
> 
> We appreciate your attention.  Thank you!
> 
> Scott Neslin
> Prasad Vana
> 
> Dartmouth College


Hi,

Presuming that you are talking about the glm() function, as there is no GLM 
package as far as I can see, R model objects have a structure that can be 
viewed using the str() function. The help for this function can be viewed using:

   ?str

You can then use:

  str(summary(YourModelObject))

That will give you some insights into the model object components and that same 
str() function is valuable for investigating other objects as well.

That being said, R's model objects typically have 'extractor' functions to make 
it easy to obtain commonly used components of the model object, which can be 
complicated.

The R manual "An Introduction to R", has a section on some of these:

    
https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Generic-functions-for-extracting-model-information
 
<https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Generic-functions-for-extracting-model-information>

Thus, for example, using:

  coef(summary(YourModelObject))

will return the matrix of coefficients and related parameters from the summary 
model object.

Once you have that matrix object, you can write it out to a CSV file using 
?write.csv, where the CSV file can then be opened with or imported into Excel.

So the steps might be along the lines of:

  my.coef <- coef(summary(YourModelObject))

  write.csv(my.coef, file = "MyCoefficients.csv")


The R Data Import/Export manual:

  https://cran.r-project.org/doc/manuals/r-release/R-data.html 
<https://cran.r-project.org/doc/manuals/r-release/R-data.html>

has some insights into pathways for getting data to and from R, including some 
packages that can directly write Excel files. You may wish to review that 
manual as well.

Regards,

Marc Schwartz



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to