Need help in R (Statistic Programe)

  • Thread starter Philip Wong
  • Start date
In summary, the conversation discusses using R to plot PC scores using a group variable as the plotting score. The steps taken include loading the library called MASS, feeding in the data file, log transforming the data, renaming the data, and using the princomp function to print the first two components. The participant questions whether they did it correctly and suggests using the eqscplot and text functions instead.
  • #1
Philip Wong
95
0
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!
 
Physics news on Phys.org
  • #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:

Related to Need help in R (Statistic Programe)

1. What is R and why is it used for statistical analysis?

R is a free and open-source programming language and software environment that is widely used in statistical computing and graphics. It is popular among scientists, researchers, and data analysts due to its powerful statistical capabilities and its ability to handle large datasets.

2. How do I get started with R for statistical analysis?

To get started with R, you can download and install the R software and the RStudio integrated development environment (IDE). RStudio provides a user-friendly interface for writing and running R code. There are also many online resources and tutorials available for learning R.

3. What are some common statistical analysis techniques in R?

R offers a wide range of statistical analysis techniques, such as linear and nonlinear modeling, time-series analysis, cluster analysis, and hypothesis testing. It also has a large number of packages that provide specialized functions for different types of data analysis.

4. Can R handle big data?

Yes, R has the capability to handle large datasets and perform complex statistical analyses on them. However, for extremely large datasets, it may be necessary to use specialized software or parallel processing techniques to improve performance.

5. How can I troubleshoot common issues in R?

If you encounter errors or have trouble running your code in R, it is important to check for typos, missing parentheses or brackets, and other syntax errors. You can also refer to online forums and documentation for help, or seek assistance from experienced R users or consultants.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
3K
  • STEM Career Guidance
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • Computing and Technology
Replies
2
Views
136
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Atomic and Condensed Matter
Replies
7
Views
506
  • Programming and Computer Science
Replies
3
Views
4K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
2K
Replies
9
Views
344
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top