RCT <- read.table(file="Analyzing RCT.txt", header=TRUE, dec = ",")
head(RCT)
##      SP Oil Capsule Group Interv_length Compliance Age1 Height1  BMI1
## 1 4.373   1       1    11            56          1   29   1.775 23.55
## 2 4.342   1       1    11            56          3   24   1.770 26.24
## 3 4.335   1       1    11            55          3   27   1.690 22.55
## 4 4.374   1       1    11            62          3   20   1.780 25.44
## 5 4.344   1       1    11            56          3   24   1.755 20.88
## 6 4.316   1       1    11            63          3   23   1.795 23.34
##   Weight1 WeightInc1_2 RBCn3PUFA_B1 RBCn3PUFA_B2 TG1_fast TG2_fast B1_LDLC
## 1    74.2            1         7.27         7.85     0.65     0.62    2.00
## 2    82.2            1         6.35         6.05     1.48     1.99    3.06
## 3    64.4            1         6.03         5.94     1.22     0.61    2.51
## 4    80.6            1         6.01         6.23     1.25     0.95    2.52
## 5    64.3            0         5.80         5.76     0.89     0.80    1.80
## 6    75.2            1         5.84         5.99     0.59     0.93    2.54
##   B2_LDLC B1_HDLC B2_HDLC b2_crp HOMA_B1 HOMA_B2 SBP_B2 DBP_B2
## 1    1.95    1.31    1.31   0.24    2.04    3.12    125     63
## 2    3.47    1.30    1.35   2.56    2.67    3.10    121     69
## 3    1.78    1.30    1.43   0.72    1.16    0.80    114     63
## 4    2.47    1.31    1.54   1.77    2.40    2.79    129     63
## 5    1.83    1.18    1.21   0.60    0.54    0.66    114     63
## 6    2.93    1.23    1.25   0.24    1.43    1.33    117     67
RCT$Capsule <- factor(RCT$Capsule)
RCT$Oil<- factor(RCT$Oil)

Fisk <- subset(RCT, RCT$Capsule == 2)
Oliven <- subset(RCT, RCT$Capsule == 1)
Raps <- subset(RCT, RCT$Oil == 2)
Solsikke <- subset(RCT, RCT$Oil == 1)

hist(RCT$BMI1)

qqnorm(RCT$BMI1)
qqline(RCT$BMI1)

with(RCT, wilcox.test(RCT$Compliance~RCT$Capsule))
## Warning in wilcox.test.default(x = c(1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, :
## cannot compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  RCT$Compliance by RCT$Capsule
## W = 481.5, p-value = 0.6684
## alternative hypothesis: true location shift is not equal to 0
t.test(Fisk$BMI1,Oliven$BMI1)
## 
##  Welch Two Sample t-test
## 
## data:  Fisk$BMI1 and Oliven$BMI1
## t = -1.868, df = 61.988, p-value = 0.06648
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.76344114  0.05970703
## sample estimates:
## mean of x mean of y 
##  22.34419  23.19606
t.test(Raps$BMI1,Solsikke$BMI1)
## 
##  Welch Two Sample t-test
## 
## data:  Raps$BMI1 and Solsikke$BMI1
## t = 1.3839, df = 61.544, p-value = 0.1714
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.2846669  1.5650971
## sample estimates:
## mean of x mean of y 
##  23.11355  22.47333
m1 <- lm(BMI1~Capsule, RCT)
summary(m1)
## 
## Call:
## lm(formula = BMI1 ~ Capsule, data = RCT)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.0642 -1.2242 -0.2542  1.2169  4.2058 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  23.1961     0.3179  72.972   <2e-16 ***
## Capsule2     -0.8519     0.4567  -1.865   0.0669 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.826 on 62 degrees of freedom
## Multiple R-squared:  0.05313,    Adjusted R-squared:  0.03785 
## F-statistic: 3.479 on 1 and 62 DF,  p-value: 0.0669
m2 <- lm(BMI1~Oil, RCT)
summary(m2)
## 
## Call:
## lm(formula = BMI1 ~ Oil, data = RCT)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1933 -1.3135 -0.3934  1.0390  4.0367 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  22.4733     0.3217  69.851   <2e-16 ***
## Oil2          0.6402     0.4623   1.385    0.171    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.848 on 62 degrees of freedom
## Multiple R-squared:  0.03001,    Adjusted R-squared:  0.01436 
## F-statistic: 1.918 on 1 and 62 DF,  p-value: 0.171