New to R, error when trying to run Investigate function for MCA results

Hi, I'm incredibly new to R (started about 2 days ago) and I've been searching all the forums for various issues. I've usually found a work around but I can't seem to get the investigate function to work quite right.

It will run, but then hits an error. The following is the error I'm getting.

> res.mca = MCA(poly, graph = FALSE)
> Investigate(res.mca, file = "MCA.Rmd", document = c("word_document", "pdf_document"))
-- creation of the .Rmd file (time spent : 0s) --

-- detection of outliers (time spent : 0.05s) --
0 outlier(s) terminated 

-- analysis of the inertia (time spent : 0.1s) --
Error in checkForRemoteErrors(val) : 
  7 nodes produced errors; first error: argument to 'which' is not logical
In addition: Warning messages:
1: In if (document == "Word" | document == "word" | document == "doc" |  :
  the condition has length > 1 and only the first element will be used
2: In if (document == "html" | document == "HTML" | document == "HTML_document") { :
  the condition has length > 1 and only the first element will be used
3: In if (document == "pdf" | document == "PDF") { :
  the condition has length > 1 and only the first element will be used
4: In if (document == "word_document") { :
  the condition has length > 1 and only the first element will be used

I found a post on stack overflow that mentioned trying traceback(), but what came back means absolutely nothing to me.

> traceback()
11: stop(count, " nodes produced errors; first error: ", firstmsg, 
        domain = NA)
10: checkForRemoteErrors(val)
9: staticClusterApply(cl, fun, length(x), argfun)
8: clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, 
       FUN = fun, ...)
7: do.call(c, clusterApply(cl = cl, x = splitList(X, nchunks), fun = lapply, 
       FUN = fun, ...), quote = TRUE)
6: parLapply(cl = cl, X = as.list(X), fun = FUN, ..., chunk.size = chunk.size)
5: parSapply(clust, 1:100, function(x, ind, factors, row.w) {
       X <- tab.disjonctif(sapply(factors, function(x, ind) {
           as.factor(sample(x, ind, replace = TRUE))
       }, ind = ind))
       while (ncol(X) != sum(factors)) {
           X <- tab.disjonctif(sapply(factors, function(x, ind) {
               as.factor(sample(x, ind, replace = TRUE))
           }, ind = ind))
       }
       X <- X * (row.w/sum(X))
       svd.triplet(t(t(X/rowSums(X))/colSums(X)) - 1, row.w = rowSums(X), 
           col.w = colSums(X))$vs^2
   }, ind = ind, factors = factors, row.w = row.w)
4: t(parSapply(clust, 1:100, function(x, ind, factors, row.w) {
       X <- tab.disjonctif(sapply(factors, function(x, ind) {
           as.factor(sample(x, ind, replace = TRUE))
       }, ind = ind))
       while (ncol(X) != sum(factors)) {
           X <- tab.disjonctif(sapply(factors, function(x, ind) {
               as.factor(sample(x, ind, replace = TRUE))
           }, ind = ind))
       }
       X <- X * (row.w/sum(X))
       svd.triplet(t(t(X/rowSums(X))/colSums(X)) - 1, row.w = rowSums(X), 
           col.w = colSums(X))$vs^2
   }, ind = ind, factors = factors, row.w = row.w))
3: eigenRef(res, dim = NULL, q = q, time = time, parallel = parallel)
2: inertiaDistrib(res, file = file, ncp = ncp, time = time, figure.title = paste("Figure", 
       compteur), graph = FALSE, options = options)
1: Investigate(res.mca, file = "MCA.Rmd", document = c("word_document", 
       "pdf_document"))

I believe I have the lastest version of everything installed. I'm using FactoMineR, Factoshiny, FactoInvestigate, factoextra and I think ggplot2. I actually have most of the plots I need, and most of the tables, but that report with interpretation is invaluable.

I've been able to get this far by using code from books or articles, but I'm not really understanding it enough to be able to troubleshoot this one. Any help would be greatly appreciated.

Also, I have double posted - my original post was on a google forum for FactoMineR (https://groups.google.com/forum/#!topic/factominer-users/JDeWvIz4t74), but it's really important I get these results ASAP. I'm also not sure if I've marked it as the right topic, but as the investigate function is trying ot make a .rmd file, I thought it might be best here?

Thanks
Olivia

Hi @olivia.j.m,
Welcome to the RStudio Community Forum.

Firstly, you are NOT going mad! I get the same errors when I run the FactoMiner and FactoInvestigate help examples under R-4.0.0 on Windows 10 using both RStudio and RGui (with latest versions of RStudio and all packages).

The solution is to run an older version of R: R-3.6.3. When I switched, everything ran as expected, and I suspect that it will also do so with your data.

You can have more than one version of R installed on your machine at once. R-3.6.3 will have a different user-library for packages, so you'll need to install the required ones again. If you hold-down <shift><ctrl> when you start RStudio, you will be given a list of available R versions to run with. You can find older versions of R on your local CRAN mirror site by searching for "previous releases".

This is, hopefully, a short-term fix until the problems with the packages are sorted out.

Good luck.
HTH

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

Ah, thank you so much! That worked perfectly!

I realised the same thing was causing Factoshiny to error out as well when trying to run the report, so I used that too.

Thanks again, it's really appreciated, you've just helped me get my paper in by deadline!

1 Like