tst
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			mod <- summary(aov(res~fac1*fac2))#
			p <- p + annotate("table", table[1], table[2], table = mod,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
td
summary(td)
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			mod <- summary(aov(res~fac1*fac2, data))#
			p <- p + annotate("table", table[1], table[2], table = mod,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
str(td)
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			mod <- summary(aov(res~fac1*fac2, data = data))#
			p <- p + annotate("table", table[1], table[2], table = mod,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(aov(res~fac1*fac2, data = data))#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
?aov
summary(aov(data = td, r ~ f1*f2))
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(aov(data[,res]~data[,fac1]*data[,fac2]))#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(aov(data[,res]~data[,fac1]*data[,fac2]))#
			p <- p + annotate("table", table[1], table[2], table = mod,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(aov(data[,res]~data[,fac1]*data[,fac2]))#
			 chk <<- mod#
			p <- p + annotate("table", table[1], table[2], table = mod,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
?attr
attributes(chk) <- "data.frame"
attributes(chk) <- list("data.frame")
attributes(chk)
attributes(chk) <- list(class = "data.frame")
str(as.data.frame(chk))
str(chk)
str(unlist(chk))
chk$Classes
chk$Df
print(chk)
xtable(chk)
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(lm(data[,res]~data[,fac1]*data[,fac2]))#
			 chk <<- mod#
			p <- p + annotate("table", table[1], table[2], table = mod,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(aov(data[,res]~data[,fac1]*data[,fac2]))#
			 chk <<- mod#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- summary(aov(res ~ fac1 * fac2, data = data))#
			 chk <<- mod#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- aov(res ~ fac1 * fac2, data = data))#
			 chk <<- mod#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- aov(res ~ fac1 * fac2, data = data)#
			 chk <<- mod#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
chk
rxnNorm <-#
function(data = NULL, res = NULL,#
	fac1 = NULL, fac2 = NULL, fac2cols = NULL,#
	freckles = FALSE, type = c("connect", "fitLine"),#
	method = c("sem", "iqr", "mad", "box", "sem95"),#
	table = NULL, xlab = NULL, ylab = NULL, title = NULL, ...) {#
#
#
#
#
#
#
#
#
#
#
	require(ggplot2)#
	require(ChemoSpec) #
	require(plyr)#
	require(ggExtra)#
	#
	if (is.null(fac2cols)) stop("You need to supply fac2cols")#
	#
	#
	#
	#
	#
	keep <- c(res, fac1, fac2)#
	data <- data[, keep]#
	data <- na.omit(data)#
#
	#
		#
	p <- ggplot(data, aes_string(x = fac1, y = res, color = fac2,#
		group = fac2))#
#
	#
#
	if (freckles) {#
		jit <- position_jitter(width = 0.05, height = 0.0)#
		p <- p + geom_jitter(position = jit, size = 1.0) #
		}#
	#
	if (method == "box") { #
		p <- p + geom_boxplot(width = 0.2)#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "sem") {#
		p <- p + stat_summary(fun.data = "seXy")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "sem95") {#
		p <- p + stat_summary(fun.data = "seXy95")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "mean", geom = "line")#
				}#
		}#
		#
	if (method == "mad") {#
		p <- p + stat_summary(fun.data = "seXyMad")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
		#
	if (method == "iqr") {#
		p <- p + stat_summary(fun.data = "seXyIqr")#
		if (type == "connect") {#
			p <- p + stat_summary(fun.y = "median", geom = "line")#
				}#
		}#
	#
	if (type == "fitLine") {#
		p <- p + geom_smooth(method = "lm", se = FALSE)#
		#
		}#
		#
	#
	#
	p <- p  + scale_colour_manual(name = "", values = fac2cols) +#
		opts(axis.text.x = theme_text(colour = "black"),#
		axis.text.y = theme_text(colour = "black"),#
		axis.ticks = theme_blank()) + opts(...)		#
#
	#
	#
    if (!is.null(title)) p <- p + opts(title = title)#
    if (!is.null(xlab)) p <- p + xlab(xlab)#
    if (!is.null(ylab)) p <- p + ylab(ylab)#
#
#
#
	#
	#
#
	if (!is.null(table)) {#
		#
		if (type == "connect") {#
			counts <- count(data, vars = c(fac2, fac1))#
			colnames(counts) <- c(fac2, fac1, "count")#
#
			p <- p + annotate("table", table[1], table[2], table = counts,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
			}#
#
		if (type == "anova") {#
			 mod <- anova(res ~ fac1 * fac2, data = data)#
			 chk <<- mod#
			#
				#
				#
               	#
               	#
			}#
#
		if (type == "fitLine") {#
			lvls <- levels(data[,fac2])#
			nl <- length(lvls)#
			m <- c()#
			b <- c()#
			r2 <- c()#
			for (i in 1:nl) {#
				dat <- subset(data, data[,fac2] == lvls[i])#
				mod <- lm(dat[,res] ~ dat[,fac1])#
				m[i] <- round(mod$coef[2], 2)#
				b [i]<- round(mod$coef[1], 2)#
				r2[i] <- round(cor(dat[,fac1], dat[,res])^2, 4)#
				#
				}#
				#
			mod.res <- data.frame(line = lvls, m = m, b = b, r2 = r2)#
				#
			p <- p + annotate("table", table[1], table[2], table = mod.res,#
				theme = theme.list(show.box = TRUE, separator = "black",#
				gp = gpar(cex = table[3]),#
               	show.csep = TRUE, show.rsep = TRUE, show.colnames = TRUE,#
               	show.rownames = FALSE))#
				#
			}#
		}	#
	invisible(p)#
	}
demo <- rxnNorm(data = td, res = "r", fac1 = "f1", fac2 = "f2",#
fac2cols = c("red", "blue"), freckles = TRUE, method = "sem",#
table = c(1.2, 15, 0.75),#
title = "rxnNorm Demo: x axis categorical & connected",#
type = "anova")#
print(demo)
?anova
source("/Users/bryanhanson/Documents/Research/MetabolomicsProjects/ChemometricsStuff/BAHpackages/HandyStuff/R/rxnNorm2.R")
?update.packages
update.packages(checkBuilt = TRUE, ask = FALSE)
library("ChemoSpec")
.libPaths()
?aovPCA
?ChemoSpec
?chkSpectra
Sweave("ChemoSpec.Rnw")
library(ChemoSpec)
vignette()
apca1 <- aovPCAscores(NewIR, mats, plot = 1, ellipse = "rob")
vignette("ChemoSpec")
sessionInfo()
?classPCA
