View source: R/MultiDimScaling.R
MDSmyDF | R Documentation |
Performs multidimensional scaling (MDS) on a data frame and generates a plot of the results. The function uses the ggplot2 package to create a scatterplot of the MDS coordinates with colored points based on a factor variable. The ggrepel package is used to add labels to the points without overlap.
MDSmyDF(dfx, labelsDF, factorV, title = "MDS Plot", col_vector, returnMDS = F)
dfx |
A data frame with samples as rows and variables as columns. |
labelsDF |
A data frame with the labels for each sample in the same order as dfx. |
factorV |
A vector containing the factor variable to use for coloring the points. |
title |
A character string for the title of the plot. |
col_vector |
A vector of colors to use for coloring the points. |
returnMDS |
A logical value indicating whether to return the MDS coordinates as a data frame. Default is FALSE. |
If returnMDS is TRUE, returns a data frame of the MDS coordinates. Otherwise, returns a ggplot object.
data(iris)
MDSmyDF(dfx = iris[, 1:4], labelsDF = iris[, 5], factorV = iris[, 5], title = "Iris Data MDS Plot",
col_vector = c("#FF0000", "#00FF00", "#0000FF"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.