library('lehmansociology')
library("ggplot2")

attach(addhealth)

You can edit this template to use different data sets and different variables, as well as to select specific statistics. In real data analysis you would never run all of these statistics at once.

For this example we will use the variable tvhrs and you should add code to get the descriptive statistics for radiohrs or compgamehrs.

Introduction

Data Analysis --don't forget to add code to get the descriptive statistics for radiohrs or compgamehrs (choose one).

`````r mean(tvhrs) median(tvhrs)

summary(tvhrs)

max(tvhrs) min(tvhrs) range(tvhrs) IQR(tvhrs)

Calculates the numbers associated to defined percentiles

quantile(tvhrs, c(.25, .5, .75, 1))

sd(tvhrs) var(tvhrs)

Examine your results above and answer the following questions based on the additional variable that you choose.

Do adolescents spend more time watching TV, on average than they spend [listening to the radio or playing computer games]? 
How much more time do they spend on that activity compared to the activity that they do less?

Look at your results for "quantile" and IQR. Are they consistent with what you would expect to see given your understanding of the IQR? Explain.

Look at your results for "var" and "sd". Are they consistent with what you would expect to see given your understanding of variance and standard deviation? Explain.

Which activity--watching TV or [listening to the radio or playing computer games]--has greater variation? Explain your answer using the results.

Write one sentence interpreting the mean and standard deviation of [radiohrs or compgamehrs].

Here we can ask for a histogram of tvhrs and `radiohrs` or `compgamehrs` (choose one). You will need to add code to get the histogram for your second variable. Be sure to add accurate and descriptive labels for the axes and a title.
````r

ggplot(addhealth, aes(tvhrs)) + 
  geom_histogram(binwidth = 1, aes(  y=(..count..)/sum(..count..) * 100)) + 
  labs(y="Percent",     x=" ") +
  ggtitle("Fig 1 :")

Does the distribution of tvhrs or [radiohrs or compgamehrs] appear to be more skewed? Explain.



elinw/lehmansociology documentation built on May 16, 2019, 3 a.m.