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.
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.
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)
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.
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)
A: Cocaine is the most used by black race. Alcohol and heroin used frequency by white race are the heighest among others.
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.