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

data: eyes_and_empathy$empathy

t = 3.2549, df = 13, p-value = 0.006269


alternative hypothesis: true mean is not equal to 30
95 percent confidence interval:
36.86936 63.98778
sample estimates:
mean of x
50.42857
Without getting into the details, understand that this output, t.result , is a
list.
To show this, you use $ to focus on some of the components:
> t.result$data.name
[1] "eyes_and_empathy$empathy"
> t.result$p.value
[1] 0.006269396
> t.result$statistic
t
3.254853
Data frames
A list is a good way to collect data. A data frame is even better. Why? When you
think of data for a group of individuals — like the 14 people in the example in the
earlier section — you typically think in terms of columns that represent the data
variables (like eyes_code , eyes , and empathy ) and rows that represent the indi-
viduals. And that’s a data frame. If the terms data set or data matrix come to
mind,
you’ve pretty much got it.
The function data.frame() works with the existing vectors to get the job done:
> e <- data.frame(eye_color,feye_color,empathy_score)
> e
eye_color feye_color empathy_score
1 2 blue 15
2 2 blue 21
3 4 gray 45
4 1 amber 32
5 5 green 61
6 5 green 74
7 5 green 53
8 6 hazel 92
9 1 amber 83

You might also like