Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Need help in R (Statistic Programe)!

  1. May 1, 2010 #1
    hello,
    ok here is the situation, I wanted use R to plot a PC scores using a group variable (which is an external variable) as the plotting score. the command for printing the PC scores is prin$x. Below is some steps I've took so far:

    > library(MASS) //loading the library called MASS
    > island.df=read.csv(file.choose(),header=T) //feeding in the data file I want to do analyze on
    > log.island.df=log((island.df[,4:10])+1) //log transform my data, because it was skewed
    > x=island.df //rename my data into x, for easier used future
    > prin=princomp(x[,4:10])
    > scores=(x~as.factor(group)) //factorize the group variable as the plotting symbol, IS THIS HOW I DO IT? Is there other ways?
    > prin$scores[,1:2] //I just want to print the first 2 components.


    IS this right? did I do something wrong? because I got no clue how the printout should looks like, so I don't know have I done it right or not!
     
  2. jcsd
  3. May 1, 2010 #2
    Or would it be better to use the following command if I want to use the group variable as the plotting symbol:
    eqscplot(prin$scores[,1:2],type="n")
    text(prin$scores[,1:2],label=as.vector(names))


    instead of just:
    > prin$scores[,1:2] //I just want to print the first 2 components.
     
    Last edited: May 1, 2010
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Need help in R (Statistic Programe)!
Loading...