Statistics

View:  
Sorted by:  

How to Use If…Else Statements in R

When using R, sometimes you need your function to do something if a condition is true and something else if it is not. You could do this with two if statements, but there’s an easier way in R: an [more…]

How to Use Vectorization with If Statements in R

Vectorization is one of the defining attributes of the R language. R wouldn’t be R if it didn’t have some kind of vectorized version of an if...elsestatement. [more…]

How to Switch Between Possibilities with If…Else Statements in R

At times, it is useful to switch between possibilities in R. The nested if...else statement is especially useful if you have complete code blocks that have to be carried out when a condition is met. But [more…]

How to Loop Through Values in R

Sometimes when making choices using R, you can use only a single value to base your choice on. You could apply that code on each value you have by hand, but it makes far more sense to automate this task [more…]

How to Use Loops with Indices in R

Using loops in R is very handy, but you can write more efficient code if you loop not over the values but over the indices. To do so, you replace the middle section in the function with the following code [more…]

How to Apply Functions on Rows and Columns in R

In R, you can use the apply() function to apply a function over every row or column of a matrix or data frame. This presents some very handy opportunities. [more…]

How to Use Factors or Numeric Data in R

Before you attempt to describe your data in R, you have to make sure your data is in the right format. This means [more…]

How to Count Unique Data Values in R

To figure out what data can be factored when working in R, let’s take a look at the dataset mtcars. This built-in dataset describes fuel consumption and ten different design points from 32 cars from the [more…]

How to Prepare Data in R

With R at your fingertips, you can quickly shape your data exactly as you want it. That’s good because in many real-life cases, you get heaps of data in a big file, and preferably in a format you can’t [more…]

How to Describe the Center of Continuous Data in R

You have the dataset and you’ve formatted it to fit your needs in R, so now you’re ready for the real work. Analyzing your data always starts with describing it. This way you can detect errors in the data [more…]

How to Describe the Variation of Data in R

A single number doesn’t tell you much about your data. Often it’s as important to know the spread of your data. You can use R to look at this spread using a number of different approaches. [more…]

How to Use Data Tables in R

A first step in every analysis, using R or not, consists of calculating the descriptive statistics for your dataset. You have to get to know the data you received before you can accurately decide what [more…]

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…]

Listings:1-2526-5051-7576-100more...

Sign Up for RSS Feeds

Education & Languages
Great Gadget Giveaway -- Enter to Win!

Inside Dummies.com