Lab 0

Your name: Rapheephan Thongkham-Uan (Nancy)

Collaborators names: Nancy_Rapheephan

Exercise 1:

Q: How many women were treated? How many men?

# code for Exercise 1 is already entered below as an example
tally( treat~sex, data=HELPrct, format="count" )
##      sex
## treat female male
##   no      55  173
##   yes     52  173

A: 52 women and 173 men were treated out of 55 women and 173 men.

Exercise 2: Making a Table

Q: Please generate a table showing the number of subjects who prefer different drugs. Which drug is most commonly preferred?

# see R tutorial #1 for code.
tally( ~substance, data=HELPrct )
## 
## alcohol cocaine  heroin 
##     177     152     124

A: Alcohol is most commonly preferred.

Exercise 3: Examining a Bar Chart

Q: Please generate a bar chart showing the number of subjects who prefer different drugs. Then identify which drug is most popular for women, and which is most popular for men. (You will have to modify the code to get the right chart.)

bargraph(~substance, group=sex, data = HELPrct, auto.key=TRUE, horizontal = TRUE)

plot of chunk unnamed-chunk-4

A: The drug most used by women in this sample is cocaine (41 people). The drung most used by men in this sample data is alcohol. *Optional R code for the bar graph, This chart is easier to define which drug is the most popular in each sex.

Exercise 4: Race and drug preference

Q: Using the ‘racegrp’ variable, write code to examine the relationship in the sample between race and preferred drug. Write a few sentences describing this relationship, making reference to any figures or charts you generate.

# fill in here.
bargraph(~substance, group=racegrp, data = HELPrct, auto.key=TRUE, horizontal = TRUE)

plot of chunk unnamed-chunk-5

A: Cocaine is the most used by black race. Alcohol and heroin used frequency by white race are the heighest among others.

Exercise 5: Generalizing to the Population

Q: You have explored some relationships in the above between different variables. Do these data give you evidence that these relationships would hold for the US population in general? Why or why not. Explain in one or two sentences.

A: From help(HELPrct). I don’t think that we could claim that these relationships would hold for Us population. I think we need to analysis more about the relationships among each variables in the data such as age, drugrisk, number of drinks etc.