Questions tagged [prcomp]

The R Stats Package function prcomp is used to perform a principal components analysis on the given data matrix. It returns the results as an object of class ```prcomp```.

The calculation is done by a singular value decomposition of the (centered and possibly scaled) data matrix, not by using eigen on the covariance matrix. This is generally the preferred method for numerical accuracy. The print method for these objects prints the results in a nice format and the plot method produces a scree plot.

Vignette: link

source code: link

44 questions
0
votes
1 answer

Confidence intervals in PCA by group with prcomp

I'm working on an RNA-seq analysis and I'm interested in what genes are driving tissue-specific variation in gene expression. PCAsare common in RNA-seq analyses, but most packages (e.g. DESeq2) only take it as far as the 2D plot. Therefore, I've…
Alex
  • 261
  • 2
  • 5
  • 11
0
votes
1 answer

How to scale results for PCA?

I have to perform a PCA on a high-dimensional dataset with the infrared spectra of different wines and then plot it in 2D. I have to color the red wines in red and the white wines in turquoise on the plot. This is the code I came up with: wine_pca…
0
votes
1 answer

R- infinite or missing values in 'x' for prcomp()

Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x' I am using prcomp() and got this error message. I tried to do a reprex but could not reproduce the error. I tried: df[is.na(df)] <- 0##NA values to 0 df <-df[which(rowSums(df) >…
takeITeasy
  • 350
  • 3
  • 19
0
votes
0 answers

prcomp error: "undefined columns selected"

I am trying to build a PCA with a matrix of labeled numeric data. I am trying to select only certain columns (6-78) to include in the PCA, but have an error (syntax?) Here's the code: cytokines.pca <- prcomp(PICHCytokines[,c(6:78)], center = TRUE,…
0
votes
1 answer

I have labelled the data matrix for PCA. How to colour them according to each label in PCA using r?

My data matrix has 100 rows and 900 columns. Here each row represents a IR spectra. The column represents the wavenumbers. The first 23 rows belong to different IR spectra from the same sample (i.e spectra from 23 different positions in the sample).…
0
votes
1 answer

How would I split a histogram or plot that show the number of main Principal Components?

I have performed PCA Analysis using the prcomp function apart of the FactoMineR package on quite a substantial dataset of 3000 x 500. I have tried plotting the main Principal Components that cover up to 100% of cumulative variance proportion with a…
Matt.W
  • 5
  • 2
0
votes
1 answer

Display the name of corresponding PC when using prcomp for PCA in r

I use prcomp to run PCA in r. When I output the summary, i.e. standard deviation, proportion of variance, cumulative proportion, the results are always ordered and the actual column name is replaced by PC1, PC2. Thus, I cannot tell the exact…
Harry
  • 331
  • 1
  • 4
  • 14
0
votes
0 answers

Using factor values in PCA Analysis (using prcomp)

I am trying to figure out how I can incorporate the factor/levels into my PCA analysis. Suppose I have the following: > df <- data.frame(col1=c("A", "B", "C", "D"), col2=c(1, 2, 3, 4)) > str(df) 'data.frame': 4 obs. of 2 variables: $ col1:…
Denis
  • 11,796
  • 16
  • 88
  • 150
0
votes
1 answer

Column label as variable name when using prcomp

I have a data frame* with column labels. How can I use, or show, those column labels instead of column names when, for instance, using prcomp? (The function get_label below, is from the package sjlabelled.) > get_label(spss.wvs) %>% head(2) …
krissen
  • 63
  • 10
0
votes
0 answers

Prcomp: info on scale argument

I was using prcomp() on R for the first time and I was wondering on the description about the scale argument, this part in particular: The default is FALSE for consistency with S, but in general scaling is advisable. I couldn't find in the rest of…
D.K.
  • 47
  • 7
0
votes
1 answer

Low PCA loadings (especially on PC1 and most others)

I have a set of 100 variables and aim to reduce my data dimension for further subsequent analyses. There are about 300 observations. Upon prcomp() in R (with retx= TRUE), my PC1's loadings (abs) are all below 0.20. And, most other PCs' loadings…
mchsu
  • 31
  • 1
  • 5
0
votes
1 answer

Error reproducing pca plot using scatter3D

I have performed principal component analysis on mtcars dataset and plotted it using scatter3D using the code given…
-1
votes
2 answers

ggbiplot worked previously with prcomp, now will not

ggbiplot used to work with no problems using prcomp but now does not. All I receive is the following error code: Error in plot_label(p = p, data = plot.data, label = label, label.label = label.label, : Unsupported class: prcomp I have…
-1
votes
1 answer

How to interpret a plot of promp result?

My PCA result using prcomp() function is summarised and plot as followings. How to interpret the plot results? It shows in some online article that the points present the amount of variance attributed to the different principal components. However,…
HappyCoding
  • 5,029
  • 7
  • 31
  • 51
1 2
3