could not find function "PCA"

Hello!

Brand new user to R. I do not have any coding experience. Did a walkthrough install of R in class and worked fine.

In class, 2 days ago, this ran fine:
Sensory_Reps.pca = PCA(Sensory_Reps [,-c(1)], scale.unit=FALSE, ncp=5, graph=TRUE)

I imported a data set (Beer_Data , it showed up with 1599 obs. of 11 variables) and ran:
Beer_Data.pca = PCA(Beer_Data , scale.unit=FALSE, npc=5, graph=TRUE)

Trying to run either now gets a message like:
Error in PCA(Sensory_Reps[, -c(1)], scale.unit = FALSE, ncp = 5, graph = TRUE) :
could not find function "PCA"

Appreciate the help
JDM

Hi @jdment ,

The PCA() function is part of the FactoMineR package.

So you need to load the package:

library(FactoMineR)

If you see this message:

Error in library(FactoMineR) : there is no package called ‘FactoMineR’

... then it means that the package is not installed on your machine and to install it just do this and wait that it's installed:

install.packages("FactoMineR")

Then load the package again: library(FactoMineR) and the PCA() function will be available.

Thanks! got it installed and it ran. Now getting an error: unused argument (npc = 5)

When I take that out of the command line, I do get a graph but the dimension 1 is 99.99% and Dim 2 is 0.0057%. The graph is basically a horizontal line. Is there a code I can insert to expand the graph on the y axis?

If you get an error like unused argument check that you made no typing error.
Instead of npc = 5 try ncp = 5.

Thanks for your reply- unfortunately, no joy. I only get a straight line of data. It doesn't matter if I use npc or ncp.

Well, it's a different question from the initial one. I would rather recommend you take a look at a few resources first:

You can also us data sets that come with the FactoMineR package, here's how you can find the list.

data(package = "FactoMineR")

If you need help with your specific case, I would recommend you post a new question with the data and code that you're using, here's how:

Good luck with the topic.

Great- thanks! I'll review the tutorials.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.