The categorical variable I'm using has four possible outcomes (ResJobLocationChoice). I want to find the n observations, mean, standard deviation, and min/max for each outcome using multiple variables (categorical and continuous). Preferably in 1 table.
I've tried but I haven't been able to get it working with multiple variables.
with(data_df, table(Female, ResJobLocationChoice))
with(data_df, do.call(rbind, tapply(Wage, ResJobLocationChoice, function(x) c(Mean = mean(x), St.Dev. = sd(x)))))
I also tried using stargazer, but to no success:
data_df %>%
group_by(ResJobLocationChoice) %>%
stargazer(data_df[c("Wage","CommuteTime", "HousingPrice")], type="text",
digits=2, title="Residential-Job Location Choice")
CodePudding user response:
As there is no replication data available have used population data inbuilt in R. Create the table with summary stats and then use stargazer with summary = FALSE
population %>%
group_by(country) %>%
summarise(amean=round(mean(population),2),
asd=round(sd(population),2)) %>%
stargazer(type = "text", summary=FALSE)