Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:42:20+00:00 2026-06-02T04:42:20+00:00

I’m running an R script generating plots of the PCA analysis using FactorMineR .

  • 0

I’m running an R script generating plots of the PCA analysis using FactorMineR.

I’d like to output the coordinates for the generated PCA plots but I’m having trouble finding the right coordinates. I found results1$ind$coord and results1$var$coord but neither look like the default plot.

I found
http://www.statistik.tuwien.ac.at/public/filz/students/seminar/ws1011/hoffmann_ausarbeitung.pdf
and
http://factominer.free.fr/classical-methods/principal-components-analysis.html
but neither describe the contents of the variable created by the PCA

library(FactoMineR)
data1 <- read.table(file=args[1], sep='\t', header=T, row.names=1)
result1 <- PCA(data1,ncp = 4, graph=TRUE) # graphs generated automatically
plot(result1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:42:22+00:00Added an answer on June 2, 2026 at 4:42 am

    I found that $ind$coord[,1] and $ind$coord[,2] are the first two pca coords in the PCA object. Here’s a worked example that includes a few other things you might want to do with the PCA output…

    # Plotting the output of FactoMineR's PCA using ggplot2
    #
    # load libraries
    library(FactoMineR)
    library(ggplot2)
    library(scales)
    library(grid)
    library(plyr)
    library(gridExtra)
    #
    # start with a clean slate
    rm(list=ls(all=TRUE)) 
    #
    # load example data
    data(decathlon)
    #
    # compute PCA
    res.pca <- PCA(decathlon, quanti.sup = 11:12, quali.sup=13, graph = FALSE)
    #
    # extract some parts for plotting
    PC1 <- res.pca$ind$coord[,1]
    PC2 <- res.pca$ind$coord[,2]
    labs <- rownames(res.pca$ind$coord)
    PCs <- data.frame(cbind(PC1,PC2))
    rownames(PCs) <- labs
    #
    # Just showing the individual samples...
    ggplot(PCs, aes(PC1,PC2, label=rownames(PCs))) + 
      geom_text() 
    

    enter image description here

    # Now get supplementary categorical variables
    cPC1 <- res.pca$quali.sup$coor[,1]
    cPC2 <- res.pca$quali.sup$coor[,2]
    clabs <- rownames(res.pca$quali.sup$coor)
    cPCs <- data.frame(cbind(cPC1,cPC2))
    rownames(cPCs) <- clabs
    colnames(cPCs) <- colnames(PCs)
    #
    # Put samples and categorical variables (ie. grouping
    # of samples) all together
    p <- ggplot() + theme(aspect.ratio=1) + theme_bw(base_size = 20) 
    # no data so there's nothing to plot...
    # add on data 
    p <- p + geom_text(data=PCs, aes(x=PC1,y=PC2,label=rownames(PCs)), size=4) 
    p <- p + geom_text(data=cPCs, aes(x=cPC1,y=cPC2,label=rownames(cPCs)),size=10)
    p # show plot with both layers
    

    enter image description here

    # Now extract the variables
    #
    vPC1 <- res.pca$var$coord[,1]
    vPC2 <- res.pca$var$coord[,2]
    vlabs <- rownames(res.pca$var$coord)
    vPCs <- data.frame(cbind(vPC1,vPC2))
    rownames(vPCs) <- vlabs
    colnames(vPCs) <- colnames(PCs)
    #
    # and plot them
    #
    pv <- ggplot() + theme(aspect.ratio=1) + theme_bw(base_size = 20) 
    # no data so there's nothing to plot
    # put a faint circle there, as is customary
    angle <- seq(-pi, pi, length = 50) 
    df <- data.frame(x = sin(angle), y = cos(angle)) 
    pv <- pv + geom_path(aes(x, y), data = df, colour="grey70") 
    #
    # add on arrows and variable labels
    pv <- pv + geom_text(data=vPCs, aes(x=vPC1,y=vPC2,label=rownames(vPCs)), size=4) + xlab("PC1") + ylab("PC2")
    pv <- pv + geom_segment(data=vPCs, aes(x = 0, y = 0, xend = vPC1*0.9, yend = vPC2*0.9), arrow = arrow(length = unit(1/2, 'picas')), color = "grey30")
    pv # show plot 
    

    enter image description here

    # Now put them side by side in a single image
    #
    grid.arrange(p,pv,nrow=1)
    # 
    # Now they can be saved or exported...
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.