Description Usage Arguments Details Value Author(s) Examples
Plots a factor variable (such as binary yes/no, case/control, or an ordinal trait) by discrete categories (such as genotype).
1 2 3 4 5 6 | ## S3 method for class 'character'
otplot(object, x, data, ylab, xlab, col, col.mix = c("white", "black"), style = "percent", ycrop = FALSE, yext = 1.25)
## S3 method for class 'factor'
otplot(object, x, data, ylab, xlab, col, col.mix = c("white", "black"), style = "percent", ycrop = FALSE, yext = 1.25)
## S3 method for class 'numeric'
otplot(object, x, data, ylab, xlab, col, col.mix = c("white", "black"), style = "percent", ycrop = FALSE, yext = 1.25)
|
object |
The name or values of the factor variable |
x |
The name or values of the discrete category variable |
data |
A data frame containing values |
ylab |
A label for the y axis |
xlab |
A label for the x axis |
col |
A vector of colours for levels of |
col.mix |
A pair of colours to mix with |
style |
A character vector, see details |
ycrop |
Logical, whether to crop y axis to data range |
yext |
Extension of y axis to accomodate legend |
Generates a plot displaying factor data by levels of a factor.
Currently, all supported styles are variations on a barplot, with bar
heights showing either the count, fraction, or percentage of the
response factor object.
Colour mixing is not currently as flexible as it could be.
Legend placement heuristics could be improved.
Returns an invisible null. The plot is generated as a side effect.
Toby Johnson Toby.x.Johnson@gsk.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | data(aoex1)
aoex1 <- within(aoex1, {
bmicat <- cut(aoex1$bmi,
c(-Inf, 25, 30, Inf))})
## Simple example
with(aoex1, otplot(bmicat, rs123456,
ylab = "BMI category", xlab = "rs123456 genotype"))
## Illustration of different plot styles,
## using alternative function calling style
oldpar <- par(mfcol = c(2, 3))
for (style1 in c("percent", "percentall", "fraction", "fractionall", "count")) {
otplot("bmicat", "rs123456", aoex1,
ylab = "BMI category", xlab = "rs123456 genotype",
style = style1)
title(main = paste('style = "', style1, '"', sep = ""))
}
par(oldpar)
## Numerics are coerced to factors
with(aoex1, otplot(rs123456_A, rs123456,
ylab = "Numeric genotype", xlab = "rs123456 genotype"))
## Illustration of alternative colour scheme
otplot("bmicat", "rs123456", aoex1,
ylab = "BMI category", xlab = "rs123456 genotype",
col = rgb(.3, 0, .15),
col.mix = c(rgb(1, 1, .9), rgb(0, 0, .4)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.