最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ggplot2 - Multiple Correspondence Analysis with R (ExPosition library). How to add supplementary variables and plot them? - Stac

programmeradmin0浏览0评论

I need to add supplementary variables to my Multiple Correspondence Analysis in R. I need to use ExPosition library for eigenvalues correction and plot both the active and supplementary variables using the coordinates output. This is my code:

data(poison)
mca_active <- poison[3:4]
mca_supp <- poison[5:7]

MCA = epMCA(mca_active, make_data_nominal = TRUE, DESIGN = NULL, make_design_nominal = TRUE,
      masses = NULL, weights = NULL, hellinger = FALSE,
      symmetric = TRUE, correction = c("b"), graphs = FALSE, k = 0)

#creating df from coordinates
coord <- as.data.frame(MCA[["ExPosition.Data"]][["fj"]])

#plotting
library(tidyverse)
library(ggplot2)
library(ggrepel)
coord_for_plot <- coord %>%
  select(V1, V2)
ggplot(coord_for_plot, aes(x=V1, y=V2)) +
  geom_point() + geom_text_repel(label = rownames(coord_for_plot)) +
  geom_vline(xintercept = 0) +geom_hline(yintercept = 0) +
  labs(x = "Dim 1", y = "Dim 2")

How can i add supp variables in my code?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论