Researcher was interested in the side effects of radiation therapy on patents suffering cancerous lesions. In particular he was interested in the effect of radiation therapy on Mental dexterity. Each patient was scored (Pre.test) on a mental dexterity test prior to treatment. They were again scored on a similar test (Post.Test) one month after treatment began.

N1 = 16 were not given radiation and served as controls,

N2 = 19 were given radiation dosage in the range 25-50,

N3 = 18 were given radiation dosage in the range 75-125, and

N4 = 21 were given radiation dosage in the range 125-250.

In the data set,

Pre.test: mental dexterity score before test

Post.test: mental dexterity score after test Treat: indicator of dosage level

1 Import a dataset called “mental.csv”

mental <- read.csv ("mental.csv", stringsAsFactors = TRUE)

2 Preview the dataset

library(rmarkdown)
paged_table(mental)
plot(mental$Pre.test, col=as.numeric(mental$Treat))

plot(mental$Post.test, col=as.numeric(mental$Treat))

3 Numerical measures

mean (mental$Pre.test)
## [1] 50.77333
median (mental$Pre.test)
## [1] 50
range (mental$Pre.test)
## [1] 23 77
var (mental$Pre.test)
## [1] 184.7182
sd (mental$Pre.test)
## [1] 13.59111
IQR (mental$Pre.test)
## [1] 19.5
x <- c(1,2,3,4,5)

plot (ecdf(x))

plot (ecdf (mental$Pre.test))
abline (h = seq (0,1, by = 0.05), lty = 1, col = "grey")

quantile (mental$Pre.test)
##   0%  25%  50%  75% 100% 
## 23.0 41.0 50.0 60.5 77.0
quantile (mental$Pre.test, probs = 0.34)
##   34% 
## 45.16
quantile (mental$Pre.test, probs = seq (0, 1, by = 0.1))
##   0%  10%  20%  30%  40%  50%  60%  70%  80%  90% 100% 
## 23.0 32.0 38.8 44.2 47.6 50.0 53.4 58.0 64.0 68.6 77.0
quantile (mental$Pre.test, probs = seq (0, 1, by = 0.01))
##    0%    1%    2%    3%    4%    5%    6%    7%    8%    9%   10%   11%   12% 
## 23.00 23.00 24.44 26.44 27.92 28.70 29.44 30.18 30.92 31.66 32.00 32.00 32.00 
##   13%   14%   15%   16%   17%   18%   19%   20%   21%   22%   23%   24%   25% 
## 34.48 36.36 37.10 37.84 38.00 38.00 38.06 38.80 39.00 39.28 40.02 40.76 41.00 
##   26%   27%   28%   29%   30%   31%   32%   33%   34%   35%   36%   37%   38% 
## 41.24 41.98 42.72 43.46 44.20 44.94 45.00 45.00 45.16 45.90 46.00 46.38 47.00 
##   39%   40%   41%   42%   43%   44%   45%   46%   47%   48%   49%   50%   51% 
## 47.00 47.60 48.00 48.08 48.82 49.00 49.30 50.00 50.00 50.00 50.00 50.00 50.74 
##   52%   53%   54%   55%   56%   57%   58%   59%   60%   61%   62%   63%   64% 
## 51.00 51.00 51.00 51.70 52.44 53.00 53.00 53.00 53.40 54.28 55.76 56.00 56.36 
##   65%   66%   67%   68%   69%   70%   71%   72%   73%   74%   75%   76%   77% 
## 57.00 57.00 57.58 58.00 58.00 58.00 58.00 58.00 58.04 59.52 60.50 61.00 61.00 
##   78%   79%   80%   81%   82%   83%   84%   85%   86%   87%   88%   89%   90% 
## 61.72 62.92 64.00 64.00 64.68 65.00 65.16 65.90 66.64 67.38 68.00 68.00 68.60 
##   91%   92%   93%   94%   95%   96%   97%   98%   99%  100% 
## 70.02 72.00 72.00 72.00 72.30 73.04 73.78 75.56 77.00 77.00

4 Boxplot

boxplot (mental$Post.test)

boxplot (Post.test ~ Treat, data = mental)

5 Change the default order of treatment

levels(mental$Treat)
## [1] "025-050R" "075-125R" "125-250R" "Control"
mental$Treat2 <- factor(mental$Treat, levels =  levels(mental$Treat)[c(4,1:3)])
levels(mental$Treat2)
## [1] "Control"  "025-050R" "075-125R" "125-250R"
paged_table(mental[, c("Treat", "Treat2")])

6 Comparison Boxplot for Looking at the Treatment Effect

boxplot (Pre.test ~ Treat2, data = mental)

boxplot (Post.test ~ Treat2, data = mental)

plot ( mental$Pre.test,mental$Post.test)

mental$dex.reduction <- mental$Pre.test - mental$Post.test
paged_table(mental)
boxplot (dex.reduction ~ Treat2, data = mental)