Summarizing Factors and Times with Stargazer

╄→尐↘猪︶ㄣ 提交于 2019-12-11 18:45:01

问题


I am not sure why it seems so difficult to find information regarding summarizing non-quantitative variables with stargazer.

I would like a summary of the following time variable (number of observations, min and max value would be great)

Time<-c("2014-07-03 10:57:35 PDT", "2014-07-03 11:02:35 PDT", 
        "2014-07-03 11:07:35 PDT", "2014-07-03 11:12:35 PDT", 
        "2014-07-03 11:17:34 PDT", "2014-07-03 11:22:34 PDT")
Time<-as.POSIXlt(Time, format="%Y-%M-%d %H:%M:%S")

And a overall sample size and number of values of each category of the following factor.

Cat.Var<-rep(c("Level 1","Level 2"), each=3)

This seems so basic but there seems to be almost no documentation related to an issue like this. Maybe the Stargazer package is not what I should be using, but I would like these tables to visually match other output I have that was created with Stargazer.

Thank you!


回答1:


Stargazer is capable of producing a well formatted summary table of factor variable. Just feed the factor variables into the ftable function from base r, and then feed that into stargazer.

For example:

stargazer(ftable(data.set$gender, data.set$year), type="text")

This summarizes the gender distribution of your data for each year. Stargazer requires ftable to have at least two factor variables, otherwise it produces an error, but this is very easy to get around if you just create a factor variable of 1's for every observation.



来源:https://stackoverflow.com/questions/25473689/summarizing-factors-and-times-with-stargazer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!