Rstudio server returns WRONG results without any message

Sorry I cannot use markdown because I believe no one can reproduce the problem. I used screenshot to describe:


(A) RStudio sessionInfo before running any code.
(B) Running the codes which give wrong results (expr is 50x30 matrix)
(C) the figure return by the last for loop you see in (B), PCA gives different results every time (not flipped axes).
(D) I believe this problem is related to Rstudio, because if I used R in the terminal directly, everything is fine.
In addition, if I call sessionInfo() after running these codes, rstudio will think forever (you see a red dot on the topright of the console window). But I am not sure these two problemd are related.

RStudio is the server version 1.2.5033

what I also tried:

  • If randomly delete one/a few rows/columns from "expr", the result could be correct again ...
  • I try princomp function (use eigen decomposition), the result is also wrong
  • deinstall and reinstall RStudio doesn't help
  • I don't think is the blas/lapack problem because the code run in terminal works fine.

This is the most wired problem I've seen. What worries me is this problem doesn't give you any error message ... Has anyone seen this problem before? Or any suggestions on what I can do to get rid of the problem? Thanks a lot.

this does seem inexplicable, I can imagine your frustrations. :frowning:
Do you have any experience using debug() or browser() type functionality to explore anomalies?
If I was in your shoes, I would attempt a debug(prcomp) and then run the script.
I just had a look now to see how gnarly it gets, and I would guess that the main 'magic' here is happening where sub function La.svd() makes a call to .Internal(La_svd(jobu, x, double(min(n, p)), u, vt))
I'd be curious if you debug(La.svd) and step through to the first internal call of La_svd. whether the same values come back, if you stop the debug, and restart the debug process again.
Like you pointed out, the randomness does seem whacky.

Its weird though because you showed in your fourth screenshot that you run fine in a pure console, and only have the issue in Rstudio IDE. and they both reference the same BLAS/LAPACK ! and I don't know what else would be relevant :thinking:

Eitherway it might be worthwhile getting the latest version of the blas/lapack that you can, just in case it was a gremlin in some interaction between Rstudio and that version of the library.

Wish you success in overcoming this

Thanks for your reply.
You are right this is related both MKL and RStudio. I now made
"/usr/lib/x86_64-linux-gnu/libblas.so.3" and ""/usr/lib/x86_64-linux-gnu/liblapack.so.3" to the default blas and lapack in "/usr/lib/", the problem has gone. (Before was MKL)

Also, the sessionInfo after running the code works fine, so this problem may also related.

That's great that you fixed it

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