Today we see how to set up multiple graphs on the same page. We use the syntax par(mfrow=(A,B))
(more…)
Today we see how to set up multiple graphs on the same page. We use the syntax par(mfrow=(A,B))
(more…)
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…)
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…)
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…)
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…)
As you may have read in one of our recent newsletters, this month The Analysis Factor hit two milestones:
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.