![]() ![]() In the next code block, we are customizing our table. Obviously, this table is far from perfect but especially when we are dealing with large data sets, these two lines are very powerful. Summary(table_one, title = "Gapminder Data") In the code block below, we are displaying how to create a table with the tableby() function and only two lines of code. We can basically customize anything and the best part about the packages is that it requires only little code. It has so much functionality that we essentially could stop right here. Create Descriptive Summary Statistics Tables in R with arsenalĪrsenal is my favorite package. Let’s start and create descriptive summary statistics tables in R. Gapminder <- lapply(gapminder, function(x) x[sample(c(TRUE, NA), Mutate(gdpPercap = factor(gdpPercap)) %>% Mutate(gdpPercap = ifelse(gdpPercap > median_gdp, "high", "low")) %>% Therefore, it is important to know how different packages deal with missing values. I did that because in the real world we rarely experience data sets without any NA values. In addition to that I also randomly introduced missing values in the data. After that, I divided the population by one million to make the table more readable. High is for countries with gdpPercap higher than the median gdpPercap and low for lower than the median gdpPercap. I transformed the gdpPercap column to a factor variable with two levels. In the code below, I am modifying the gapminder data set a little bit. In order for you to follow my code, I used the gapminder data set from the gapminder package. For additional information, there is a link to the corresponding vignette which has even more examples and code snippets. Let’s get started with a quick look at the packages we are going to present:Ĭhoosing our Data Set to Create Descriptive Summary Statistics Tables in Rįor all of these packages, I am providing some code that shows the basics behind the tables and their functionality. This is a great way to use these tables in one’s report or presentation. ![]() Moreover, one can easily knit their results to HTML, pdf, or word. Meaning, we can choose a factor column and stratify this column by its levels (very useful!). Almost all of these packages can create a normal descriptive summary statistic table in R and also one by groupings. In this blog post, I am going to show you how to create descriptive summary statistics tables in R. In addition to that, summary statistics tables are very easy and fast to create and therefore so common. Summary statistics tables or an exploratory data analysis are the most common ways in order to familiarize oneself with a data set. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |