Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Here’s what the list looks like:

> eyes_and_empathy
$eyes_code
[1] 2 2 4 1 5 5 5 6 1 3 6 3 1 4
$eyes
[1] blue blue gray amber green green green hazel amber
[10] brown hazel brown amber gray
Levels: amber blue brown gray green hazel
$empathy
[1] 15 21 45 32 61 74 53 92 83 22 67 55 42 44
As you can see, R uses the dollar sign ( $ ) to indicate each component of the
list.
So, if you want to refer to a list component, you type the name of the list, the
dol-
lar sign, and the component-name:
> eyes_and_empathy$empathy
[1] 15 21 45 32 61 74 53 92 83 22 67 55 42 44
How about zeroing in on a particular score, like the fourth one? I think you can
see
where this is headed:
> eyes_and_empathy$empathy[4]
[1] 32
Lists and statistics
Lists are important because numerous statistical functions return lists of objects.
One statistical function is t.test() . In Chapter 10, I explain this test and the
theory behind it. For now, just concentrate on its output.
I use this test to see if the mean of the empathy scores differs from an arbitrary
number — 30, for example. Here’s the test:
> t.result <- t.test(eyes_and_empathy$empathy, mu = 30)
Let’s examine the output:
> t.result
One Sample t-test

You might also like