| ggmat | R Documentation |
Matrix plot using ggplot2
ggmat(dat, column, xfctr, lwd, mcols, col_fctr, labs, vselect, vcol, xlab, ylab, main)
dat |
data.frame |
column |
select column of data.frame E.g. -1:-4 |
xfctr |
factor for xaxis |
lwd |
integer for line width |
mcols |
manual colour setting |
col_fctr |
factor for coloured groups |
labs |
character: text for plotting at additional area |
vselect |
select variable names for highlight. if it was given, 'col_fctr' must be null. if 'vselect' was named vector, names of 'vselect' were factor for colours. |
vcol |
gives vector only high light colors |
xlab |
character for x-labels |
ylab |
character for y-labels |
main |
character for main title |
## Not run:
# data
dat1 <- rskodat::dat1norep
dat2 <- dat1[1:3,]
# ggmat
rsko::ggmat(dat = dat1, column = -1:-4, xfctr = dat1$days, col_fctr = dat1$strains)
rsko::ggmat(dat = dat1, column = -1:-4, xfctr = dat1$days, col_fctr = dat1$strains,
mcols = 1:2)
rsko::ggmat(dat = dat2, column = -1:-4, xfctr = dat2$days)
# add text
library(dplyr)
dat <- Orange %>% mutate(Tree = as.character(Tree))
ggmat(dat, -1:-2, xfctr = dat$age, col_fctr = dat$Tree)
ggmat(dat, -1:-2, xfctr = dat$age, col_fctr = dat$Tree, labs = dat$Tree)
## Give variable names as vectors or named vectors for highlight lines.
slct1 <- c('X10', 'X5', 'X3')
slct2 <- setNames(slct1, c('first', 'second', 'second'))
slct3 <- setNames(names(dat2)[-1:-4], rep(c('I','II','III'), c(2,4,4)))
## vector of line colors corresponding to variable name selected.
col1 <- c('red', 'blue','green')
col2 <- c('red', 'blue')
col3 <- c(0:2)[factor(names(slct3))]
# ggmat
rsko::ggmat(dat = dat2, column = -1:-4, xfctr = dat2$days,
col_fctr = NULL, vselect=slct1, vcol=col1)
rsko::ggmat(dat = dat2, column = -1:-4, xfctr = dat2$days,
col_fctr = NULL, vselect=slct2, vcol=col2)
rsko::ggmat(dat = dat2, column = -1:-4, xfctr = dat2$days,
col_fctr = NULL, vselect=slct3, vcol=col1)
# summarised line
library(dplyr)
dat1 %>% tidyr::gather('k','v', -1:-4) %>%
group_by(strains,days) %>%
mutate(med_v=median(v)) %>%
rsko::ggmat(., column=7, col_fctr = .$strains, xfctr = .$days)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.