if(!requireNamespace('lattice', quietly = TRUE)){ install.packages('lattice', dependencies=TRUE, repos='http://cran.rstudio.com/') } library(lattice) ## This didn't work due to missing dependencies: ## ## if(!requireNamespace('RVAideMemoire', quietly = TRUE)){ ## install.packages('RVAideMemoire', dependencies=TRUE, repos='http://cran.rstudio.com/') ## } ## require('RVAideMemoire') ## ## Download the source code and install by hand: ## ## https://cran.r-project.org/web/packages/RVAideMemoire/index.html ## ## Source the code you will actuall use: ## if( file.exists('~/Software/RVAideMemoire/R/mood.medtest.R') ){ source('~/Software/RVAideMemoire/R/mood.medtest.R') } standard = c(1.0, 1.25, 1.5, 1.5, 1.0, 1.25, 1.0, 1.5) new = c(0.5, 0.75, 0.5, 1.0, 0.75, 1.25, 1.0, 1.5) standard = jitter(standard) ## used to avoid tied values new = jitter(new) drugtime = data.frame(Tmax=c(standard, new), Formulation=c(rep('Standard', length(standard)), rep('New', length(new)))) drugtime$Formulation = as.factor(drugtime$Formulation) histogram(~ Tmax | Formulation, layout=c(1, 2), data=drugtime) ## Compare the means with a t-test: ## res = t.test(standard, new) print('T-test:') print(res) ## Use a nonparametric method to compare the medians: ## res = mood.medtest(Tmax ~ Formulation, data=drugtime) print('Median Test:') print(res) ## Use the rank-sum test: ## res = wilcox.test(Tmax ~ Formulation, data=drugtime) print('Wilcox Test:') print(res)