2. Use the link http://www.hsph.harvard.ed u/fitzmaur/ala/skin.txt to obtain the
ID: 2949111 • Letter: 2
Question
2. Use the link http://www.hsph.harvard.ed u/fitzmaur/ala/skin.txt to obtain the skin cancer data studied by Greenberg et al (1990). This data set has 7081 rows and 8 columms. It also provides the data description with the name of the variables, where Y is the number of skin cancer counts. First, you need to save only this data set (no description) in your working directory. Then you need to load this data fle in R. Note that the last three columns of the dataset are the variables "Y", 'Treatment", and "Year Now use these variables to obtain treatment groups as below the meanl and variance of the skin cancer counts (Y) for the two Year 1 Year 2 Year 3 Year 4 Year 5 Treatment group placebo Mean 0.2709 0.2403 0.2474 02332 02721 Variance 0.7619 0477 0.6071 06117 0.7153 Mean 0.2979 0.2612 0.3154 0.3154 0.2985 Variance 0.6468 0.4571 1.2643 1.2643 0.8033 beta-caroteneExplanation / Answer
Paste the data in excel with the variable names as written in the description. Then open R. And then write the following code.
###############################################################
install.packages("readxl")
library(readxl)
skin <- read_excel("F:/Chegg/skin.xlsx")
View(skin)
####################################################
Now, your data is imported in R. Then, you write the following code in R to get the summary statistics.
###################################################
install.packages("dplyr")
library('dplyr')
skin %>% group_by(Year,Treatment) %>% summarize(mean=mean(Y), Variance=var(Y))
####################################################
The output you get is like this
Year Treatment mean Variance
<dbl> <dbl> <dbl> <dbl>
1 1. 0. 0.271 0.762
2 1. 1. 0.298 0.647
3 2. 0. 0.240 0.477
4 2. 1. 0.261 0.457
5 3. 0. 0.247 0.607
6 3. 1. 0.286 1.12
7 4. 0. 0.233 0.612
8 4. 1. 0.315 1.26
9 5. 0. 0.272 0.715
10 5. 1. 0.298 0.803
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.