Description Usage Arguments Details Value Note See Also Examples
While the original fortify() function in ggplot2 was used
to convert models and formulas to data.frames, it can also be used
as a hook to customise data prior to being put through the plotting
internals. Since ggplot exclusively handles data.frames, we
use fortify methods to convert S4 vector objects to base
data.frames.
1 2 3 4 5 |
model |
model or other R object to convert to data frame |
data |
original dataset, if needed |
... |
other arguments passed to methods |
The fortify methods in this package are written for two classes.
The Vector virtual class from which a broad
range of concrete classes in Bioconductor derive. The fortify method
column-binds the Vector content itself to the the result of
callling mcols() on the Vector and returns this as a base
data.frame. The column containing the Vector content will be
named .VectorClass, wherein VectorClass is the name of the
input's class.
The DataFrame class is converted to its
base R equivalent. Beware that any element metadata from the
Vectors in the DataFrame is not converted to seperate
columns.
A base R data.frame with (when applicable) S4 columns
Although S4 vectors can be converted to base R data.frames,
there is no guarantee that all functions tailored to data.frame will
work. The rbind method for data.frame for example, implicitly
converts columns to vectors. When there exists no such method for an S4
class, rbind will throw an error.
fortify for the original function in ggplot2.
1 2 3 4 5 6 7 8 9 10 | # Element metadata of Vector classes are converted to columns
x <- Rle(1:5)
mcols(x) <- DataFrame(y = LETTERS[1:5])
fortify(x)
# Vector element metadata is not converted to a column when
# fortifying a DataFrame
df <- DataFrame(x = Rle(1:5), y = Factor(LETTERS[1:5]))
mcols(df$x) <- DataFrame(z = "I'm Vector metadata")
fortify(df)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.