| plotdata | R Documentation |
Plot a dataset.
plotdata(
d,
k = NULL,
target = NULL,
type = c("pairs", "scatter", "parallel", "boxplot", "histogram", "barplot", "pie",
"heatmap", "heatmapc", "correlation", "pca", "cda", "svd", "nmf", "tsne", "som",
"words"),
legendpos = "topleft",
alpha = 200,
asp = 1,
labels = FALSE,
tsne = NULL,
nmf = NULL,
...
)
d |
A numeric dataset (data.frame or matrix). |
k |
The variable the observations are told apart by: they are coloured, grouped or,
for |
target |
The variable to be explained, read by |
type |
The type of graphic to be plotted. See the Details section on the projections. |
legendpos |
Position of the legend |
alpha |
Opacity of the plotted points, from 0 (invisible) to 255 (opaque). Useful on dense scatter plots, where points would otherwise hide each other. The legend stays opaque. |
asp |
Aspect ratio: 1 (the default) makes one unit as long on both axes, |
labels |
Indicates whether or not labels (row names) should be showned on the (scatter) plot. |
tsne |
A precomputed |
nmf |
A precomputed |
... |
Other parameters. |
type = "correlation" draws how strongly each variable relates to the target, sorted,
strongest at the top. Two different quantities, depending on the target. Against a
numeric target it is Pearson's correlation r, sign included, and the axis says so.
Against a categorical one it is the correlation ratio \eta, the square root
of the between-class share of the variance – not a Pearson coefficient computed on
class numbers, which would depend on the order the classes happen to be in and would mean
nothing beyond two classes. \eta lies in [0, 1], is defined for any number of classes
and does not depend on their coding. On exactly two classes \eta is |r| with the
classes coded 0/1, so the sign comes back and says which class the variable is larger in.
The projections (type = "pca", and the default "scatter"/"pairs" on
more than two variables) are computed on the data as they are, unscaled – plotdata
shows a dataset, whereas PCA performs a factorial analysis and centres and
scales by default. So plotdata (d, type = "pca") and plot (PCA (d)) differ
visibly when the variables have very different scales, and PCA is the one to
use for a properly scaled projection.
require (datasets)
data (iris)
# Without classification
plotdata (iris [, -5]) # Default (pairs)
# With classification
plotdata (iris [, -5], iris [, 5]) # Default (pairs)
plotdata (iris, 5) # Column number
plotdata (iris) # Automatic detection of the classification (if only one factor column)
plotdata (iris, type = "scatter") # Scatter plot (PCA axis)
plotdata (iris, type = "parallel") # Parallel coordinates
plotdata (iris, type = "boxplot") # Boxplot
plotdata (iris, type = "histogram") # Histograms
plotdata (iris, type = "heatmap") # Heatmap
plotdata (iris, type = "heatmapc") # Heatmap (and hierarchalcal clustering)
plotdata (iris, type = "pca") # Scatter plot (PCA axis)
plotdata (iris, type = "cda") # Scatter plot (CDA axis)
plotdata (iris, type = "svd") # Scatter plot (SVD axis)
plotdata (iris, type = "som") # Kohonen map
# With only one variable
plotdata (iris [, 1], iris [, 5]) # Default (data vs. index)
plotdata (iris [, 1], iris [, 5], type = "scatter") # Scatter plot (data vs. index)
plotdata (iris [, 1], iris [, 5], type = "boxplot") # Boxplot
# With two variables
plotdata (iris [, 3:4], iris [, 5]) # Default (scatter plot)
plotdata (iris [, 3:4], iris [, 5], type = "scatter") # Scatter plot
data (titanic)
plotdata (titanic, type = "barplot") # Barplots
plotdata (titanic, type = "pie") # Pie charts
## Not run:
# Reusing a previously computed t-SNE embedding instead of recomputing it
res = TSNE (iris [, -5])
plotdata (iris [, -5], iris [, 5], type = "tsne", tsne = res)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.