Reputation: 389
I want to produce a table with descriptive statistics that are 'pleasant to look at' when I knit my markdown-file to a pdf-file. My data consists of a number of categorical (19) as well as continuous (6) variables.
To be more specific, I found xtable
to be a tidy and clean table and preferable I would want to find a way of creating a descriptive table with both categorical and continuous variables in it.
UPDATE: I've been working some more on this and after receiving some comments I'm trying to reframe the questions so it becomes more clear.
What I want to do is to create a data frame with consists of the desired summary statistics (given the characteristics of the variable). Then I want to use xtable
to make it into a tidy table when I knot my rMarkdown to a pdf.
So my question is: how to a create a function that gives me the desired descriptive statistics of each variable, and put it into a data frame?
To exemplify my request here is some code.
library(xtable)
library(tidyverse)
# Loading data
data(iris)
# Calculating descriptive statistics
desc.df <- iris %>%
summarise_if(is.numeric, c(mean)
# The table
xtable(desc.df)
What I'm struggling with is to add several descriptive statistics for each variable (sd, min/max, the proportion of missing values for each variable), and to summarise the categorical variable. Can anyone help me with this?
Upvotes: 1
Views: 328
Reputation: 41
Use skim from skimr package - it provides pure text, but shows all important stuff
Upvotes: 2