Let’s create a simple bar chart in R using the barplot() command, which is easy to use.
First, we set up a vector of numbers. Then we count them using the table() command, and then we plot them.
The table() command creates a simple table of counts of the elements in a data set.
H <- c(2,3,3,3,4,5,5,5,5,6)
Now we count the elements using the table() command, as follows: (more…)
Do I really need to learn R?
Someone asked me this recently.
Many R advocates would absolutely say yes to everyone who asks.
I don’t.
(I actually gave her a pretty long answer, summarized here).
It depends on what kind of work you do and the context in which you’re working.
I can say that R is (more…)
In Part 10, let’s look at the aggregate command for creating summary tables using R.
You may have a complex data set that includes categorical variables of several levels, and you may wish to create summary tables for each level of the categorical variable.
For example, your data set may include the variable Gender, a two-level categorical variable with levels Male and Female. Your data set may include other categorical variables such as Ethnicity, Hair Colour, the Treatments received by patients in a medical study, or the number of cylinders in motor vehicles.
In any case, you may wish to produce summary statistics for each level of the categorical variable. This is where the aggregate command is so helpful. (more…)
by Lucy Fike
We know that using SPSS syntax is an easy way to organize analyses so that you can rerun them in the future without having to go through the menu commands.
Using Python with SPSS makes it much easier to do complicated programming, or even basic programming, that would be difficult to do using SPSS syntax alone. You can use scripting programming in Python to create programs that execute automatically. (more…)
In Part 9, let’s look at sub-setting in R. I want to show you two approaches.
Let’s provide summary tables on the following data set of tourists from different nations, their gender and numbers of children. Copy and paste the following array into R. (more…)
Let’s look at some basic commands in R.
Set up the following vector by cutting and pasting from this document:
a <- c(3,-7,-3,-9,3,-1,2,-12, -14)
b <- c(3,7,-5, 1, 5,-6,-9,16, -8)
d <- c(1,2,3,4,5,6,7,8,9)
Now figure out what each of the following commands do. You should not need me to explain each command, but I will explain a few. (more…)