**View:**

**Sorted by:**

### How to Calculate Data Proportions and Find the Center in R

After you have the data table with the counts, you can use R to easily calculate the proportion of each count to the total simply by dividing the table by the total counts. To calculate the proportion [more…]

### How to Plot Histograms with Your Data in R

To get a clearer visual idea about how your data is distributed within the range, you can plot a histogram using R. To make a histogram for the mileage data, you simply use the [more…]

### How to Use Frequencies or Densities with Your Data in R

By breaking up your data in intervals in R, you still lose some information. Still, the most complete way of describing your data is by estimating the [more…]

### How to Summarize a Dataset in R

If you need a quick overview of your dataset, you can, of course, always use the R command str()and look at the structure. But this tells you something only about the classes of your variables and the [more…]

### How to Plot Quantiles for Subgroups in R

Often you want to split up data analysis for different subgroups in R in order to compare them. You need to do this if you want to know how the average lip size compares between male and female kissing [more…]

### How to Extract Data from Plots in R

The hist() and boxplot() functions in R have another incredibly nice feature: You can get access to all the data R uses to plot the histogram or box plot and use it in further calculations. Getting that [more…]

### How to Track Data Correlations in R

Statisticians love it when they can link one data variable to another. R can help to find this relationship. Sunlight, for example, is detrimental to skirts: The longer the sun shines, the shorter skirts [more…]

### How to Calculate Data Correlations in R

The amount in which two data variables vary together can be described by the *correlation coefficient**.* In R, you get the correlations between a set of variables very easily by using the [more…]

### How to Deal with Missing Data Values in R

The cor() function in R can deal with missing data values in multiple ways. For that, you set the argument use to one of the possible text values. The value for the [more…]

### How to Create a Two-Way Data Table with R

A *two-way table* is a table that describes two categorical data variables together, and R gives you a whole toolset to work with two-way tables. They contain the number of cases for each combination of [more…]

### How to Look at Data Margins and Proportions in R

In categorical data analysis, many R techniques use the *marginal totals* of the table in the calculations. The marginal totals are the total counts of the cases over the categories of interest. For example [more…]

### How to Test Data Normality Graphically in R

You could, of course, plot a histogram with R for every data sample you want to look at. You can use the histogram() function pretty easily to plot histograms for different groups. [more…]

### How to Use Quantile Plots to Check Data Normality in R

Histograms leave much to the interpretation of the viewer. A better graphical way in R to tell whether your data is distributed normally is to look at a so-called quantile-quantile [more…]

### How to Test Data Normality in a Formal Way in R

The graphical methods for checking data normality in R still leave much to your own interpretation. There’s much discussion in the statistical world about the meaning of these plots and what can be seen [more…]

### How to Convert a Factor in R

Sometimes you need to explicitly convert factors to either text or numbers. To do this, you use the functions as.character() or as.numeric(). First, convert your [more…]

### How to Look at the Structure of a Factor in R

R has a special data structure for categorical data, called *factors.* Factors are closely related to characters because any character vector can be represented by a factor. To look a little bit under the [more…]

### How to Distinguish Data Types in R

In the field of statistics, being able to distinguish between variables of different types is very important. The type of data very often determines the type of analysis that can be performed. As a result [more…]

### How to Work with Ordered Factors in R

In R, there is a special data type for ordinal data. This type is called *ordered factors* and is an extension of factors that you’re already familiar with. [more…]

### How to Do More with Loops in R

R contains some of the mechanisms used in other programming languages to manipulate loops: [more…]

### How to Apply Functions to a Vector in R

The apply() function works on anything that has dimensions in R, but what if you don’t have dimensions? For that, you have two related functions from the apply family at your disposal [more…]

### How to Simplify Results (or Not) with the sapply Function in R

The sapply() function doesn’t always return a vector. In fact, the standard output of sapply is a list, but that list gets simplified to either a matrix or a vector [more…]

### How to Use the Dots Argument in R

There are multiple ways to add arguments in R. The addPercent() function rounds every percentage to one decimal place, but you can add another argument to specify the number of digits the [more…]

### How to Search for Multiple Words in R

When working with text in R, you may need to find words or patterns inside text. Imagine you have a list of the states in the United States, and you want to find out which state names consist of two words [more…]

### How to Substitute Text in R

The sub() function (short for *substitute*) in R searches for a pattern in text and replaces this pattern with replacement text. You use sub() to substitute text for text, and you use its cousin [more…]

### How to Extend Text Functionality with Stringr in R

If you’ve worked at all with the text manipulation functions of R, you probably wonder why all these functions have such unmemorable names and seemingly diverse syntax. If so, you’re not alone. [more…]