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 8564283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:09:48+00:00 2026-06-11T17:09:48+00:00

library(MASS) example(lda) plot(z) How can I access all the points in z? I want

  • 0
library(MASS)
example(lda)
plot(z)

How can I access all the points in z? I want to know the values of every point along LD1 and LD2 depending on their Sp (c,s,v).

  • 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-11T17:09:50+00:00Added an answer on June 11, 2026 at 5:09 pm

    What you are looking for is computed as part of the predict() method of objects of class "lda" (see ?predict.lda). It is returned as component x of the object produced by predict(z):

    ## follow example from ?lda
    Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
                       Sp = rep(c("s","c","v"), rep(50,3)))
    set.seed(1) ## remove this line if you want it to be pseudo random
    train <- sample(1:150, 75)
    table(Iris$Sp[train])
    ## your answer may differ
    ##  c  s  v
    ## 22 23 30
    z <- lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset = train)
    
    ## get the whole prediction object
    pred <- predict(z)
    ## show first few sample scores on LDs
    head(z$x)
    

    the last line shows the first few rows of the object scores on the linear discriminants

    > head(pred$x)
              LD1        LD2
    40  -8.334664  0.1348578
    56   2.462821 -1.5758927
    85   2.998319 -0.6648073
    134  4.030165 -1.4724530
    30  -7.511226 -0.6519301
    131  6.779570 -0.8675742
    

    These scores can be plotted like so

    plot(LD2 ~ LD1, data = pred$x)
    

    producing the following plot (for this training sample!)

    lda scores plot

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

Sidebar

Related Questions

library(ggplot2) my_title = This is a really long title of a plot that I
library(ggplot2) This code produces a nice looking plot: qplot(cty, hwy, data = mpg, colour
JS library like JQuery can be linked directly from other site (e.g. google). Usually
What library can I use to calculate dates based on date expressions? A date
What library does Firefox use for its user interface and can you use it
Summary: I'm given a series of points in 3D space, and I want to
Which library may I use to do it? You can think of it as
A library provides a class with virtual functions. Can this class be extended with
I am creating a networking library in C# that I can use in any
Should Library path point to the source files of packages? Delphi 7 documentation says

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.