R

R Graphics: Multiple Graphs and par(mfrow=(A,B))

December 16th, 2014 by

Today we see how to set up multiple graphs on the same page. We use the syntax  par(mfrow=(A,B)) (more…)


R Is Not So Hard! A Tutorial, Part 18: Re-Coding Values

August 29th, 2014 by


One data manipulation task that you need to do in pretty much any data analysis is recode data.  It’s almost never the case that the data are set up exactly the way you need them for your analysis.

In R, you can re-code an entire vector or array at once. To illustrate, let’s set up a vector that has missing values.

A <- c(3, 2, NA, 5, 3, 7, NA, NA, 5, 2, 6)

A

[1] 3 2 NA 5 3 7 NA NA 5 2 6

We can re-code all missing values by another number (such as zero) as follows: (more…)


R Is Not So Hard! A Tutorial, Part 17: Testing for Existence of Particular Values

August 25th, 2014 by

Sometimes you need to know if your data set contains elements that meet some criterion or a particular set of criteria.

For example, a common data cleaning task is to check if you have missing data (NAs) lurking somewhere in a large data set.

Or you may need to check if you have zeroes or negative numbers, or numbers outside a given range.

In such cases, the any() and all() commands are very helpful. You can use them to interrogate R about the values in your data. (more…)


R Is Not So Hard! A Tutorial, Part 16: Counting Values within Cases

August 19th, 2014 by


SPSS has the Count Values within Cases option, but R does not have an equivalent function. Here are two functions that you might find helpful, each of which counts values within cases inside a rectangular array. (more…)


R Is Not So Hard! A Tutorial, Part 15: Counting Elements in a Data Set

August 13th, 2014 by

Combining the length() and which() commands gives a handy method of counting elements that meet particular criteria.

b <- c(7, 2, 4, 3, -1, -2, 3, 3, 6, 8, 12, 7, 3)
b

Let’s count the 3s in the vector b. (more…)


Random Sample from a Uniform Distribution in R Commander

July 23rd, 2014 by

Why We Needed a Random Sample of 6 numbers between 1 and 10000

As you may have read in one of our recent newsletters, this month The Analysis Factor hit two milestones:

  1. 10,000 subscribers to our mailing list
  2. 6 years in business.

We’re quite happy about both, and seriously grateful to all members of our community.

So to celebrate and to say thanks, we decided to do a giveaway to 6 randomly-chosen  newsletter subscribers.

I just sent emails to the 6 winners this morning.

How We Randomly Generated 6 Equally Likely Values out of 10000 Using R Commander (more…)