ggfactorial: Data summarization and ggplot of multivariate statistics by...

View source: R/ggfactorial.R

ggfactorialR Documentation

Data summarization and ggplot of multivariate statistics by multiple factors

Description

This functions returns the ggplot object

Usage

ggfactorial(dat, column, y, x, reps, ycols, xcols, func, facet, type)

Arguments

dat

data frame, matrix, or vector; if 'dat' is a data frame or matrix, vector and missing 'func', return boxplot objects only.

column

column number

y

atomic vector; groups of experiment. e.g. c("setA","setA","setA","setB","setB","setB"). y_fctr is a first factor and its levels are same or less than x_fctr as second factor.

x

atomic vector; groups of experiment. e.g. c(1,2,3,1,2,3),

reps

groups of replicate experiment(optional)

ycols

colors corresponding to levels of y_fctr

xcols

colors corresponding to levels of x_fctr

func

calcurate statistics for margin 1 of 'dat'. (optional)

facet

logical; if TRUE, additional ggplot objects using facet_wrap are created. if 'type' is 'all', could not adding facet_wrap.

type

type of ggplot select from "point", "segment", "line", and "all". The default value is "point".

Value

List containing ggplot objects

Examples

# # sample dat
## Not run: 
dat1 <- rskodat::dat1
dat2 <- rskodat::dat2
dat1norep <- rskodat::dat1norep
dat2norep <- rskodat::dat2norep

# data.frame input
res1 <- ggfactorial(dat = dat1, column = -1:-4, y = strains, x = days,
                    facet = TRUE, func = mean, type = "point")
do.call(gridExtra::grid.arrange, c(res1, list(ncol = 2)))

# single column data.frame input
res2 <- ggfactorial(dat = dat2, column = -1:-4, y = strains, x = days,
                    reps = reps, type = "line")
do.call(gridExtra::grid.arrange, c(res2, list(ncol = 2)))

# single column data.frame input
res3 <- ggfactorial(dat = dat2norep, column =5, y=strains, x = days, type = "segment")
do.call(gridExtra::grid.arrange, c(res3, list(ncol = 2)))

# data.frame input and manual colour setting
col2 <- c(1,2); col3 <- c(1,2,4)
res4 <- ggfactorial(dat = dat1, column=-1:-4, y = strains, x = days,
                    ycols = col2, xcols = col3,
                    facet = TRUE, func = mean, type = "point")
do.call(gridExtra::grid.arrange, c(res4, list(ncol = 2)))

# type is 'all'
res5 <- ggfactorial(dat = dat1, column =-1:-4, y = strains, x = days, reps = reps,
                    fun = mean, type = "all")
do.call(gridExtra::grid.arrange, c(res5, list(ncol = 2)))

# none replicate factor, and function is none
res6 <- ggfactorial(dat = dat1norep, column=-1:-4, y = strains, x_fctr = days,
                    type = "none")

## End(Not run)

shkonishi/rsko documentation built on Feb. 21, 2023, 5:12 a.m.