I am making a presentation table with R markdown with certain descriptive statistics of a dataframe. To do this, I load library(printr)
and enter my variables of interest in descr(data)
, which is a command within the library summarytools
that generates a table with certain descriptive values. However, I want to add other elements to the table that is generated , such as, for example, the standard error of each variable when entering it in a glm(*)
.
That is, with my variables of interest I am creating a binomial logit model and I would like to add to the table generated by descr(data) certain results returned by the object glm
, such as the standard error of each variable .
Is there an alternative to having to create a new table from scratch? Is there a package that makes this task easier for me? Because creating such a table from scratch would take a long time for the little I want to add to the table generated by the command descr(data)
.
This is an option generating the descriptive summary with
skimr
and organizing the statistics of interest of the model withbroom
.skim()
creates summaries that can be easily passed to a data frame. Then you fit the model andtidy
pass the coefficients, error, etc. also to data frame. Then a join by variable/coefficient name and finally choose the columns that will appear in the table and rename them to Spanish in the same step.It works fine for continuous independent variables, but it obviously has problems when it is a factor, since we will have k-1 dummy variables and only one row of descriptives. A solution could be found for it by passing to
skim()
the model matrix made withmodel.matrix
or similar. In fact, in that case you could also use the same statistics of a continuous, since the mean would be the proportion of that category. The standard deviation wouldn't make much sense, anyway.