My RStudio crashes on my new Mac whenever I use the scagnostics() function.

As part of my studies I want to run the "scagnostics"-function from the R-Package scagnostics on the Boston housing data from the package "MASS". My code amounts to

install.packages("MASS")
install.packages("rJava")
# update.packages("rJava")
# update.packages("scagnostics")
library("rJava")
library("scagnostics")
library("MASS")

scagnostics(Boston)

which should install and load all necessary packages. When running the function my R occasionally crashes, which I figured must have something to do with the version of Java i have running on my Mac. After installing Java and running scagnostics(Boston) through my terminal as a cross-check (which worked seemlessly), my RStudio seemed to still have the same problem.

There were two other outcomes, where I either got the initial output of scagnostics(), with RStudio crashing in the subsequent handling, or an error, that still pointed to some Java problem. See in the code below

> scagnostics(Boston)
# The Output:
#Error in .jcall("scagnostics/Main", "[[D", "computeScagnostics", data,  : 
# java.lang.NullPointerException

Java Version: 11.0.25
Mac-Book Pro M3 with macOS Sonoma 14.4

Can somebody maybe help me, or has someone run into the same/a similar problem! Thanks in advance!

I don't think I'm likely to be of any help but is this all the code you are running in a new session? I just want to check that there is no conflicting variable in your workspace.

library("rJava")
library("scagnostics")
library("MASS")

scagnostics(Boston)

I mean a new session where under global options you have this.

BTW, that library("rJava") call is redundant as {scagnostics} will load it automatcally but it should not be doing any harm..

Hi!

Thanks for the quick reply; while the "restore .RData" option was indeed ticked, I have unticked it, cleared my workspace of all objects and inserted the code into a new R Script. Unfortunately the problem still kept occurring.

I think it likely has to do with the Java-Compilation of the scagnostics package, but it perplexes me why it runs smoothly in my Terminal then.

Just on general principles, it is a good idea to leave the "restore .RData" option unticked but if everything in running smoothly in the Mac terminal I suspect it is an RStudio problem though it could be a Java problem or a conflict with Java.

Are you running the most recent version of RStudio? If so you might want to revert one version and see what happens.

I have no problem with your code with Ubuntu 22.04, RStudio 2024.07.0+330 "Cranberry Hibiscus" and R version 4.4.1.

Oh and just on general principles try Resetting RStudio Desktop's State.

Sorry not to be of more help.

Hi @joeback
This link reports a problem with Java on MacOS 14.4 with Apple silicon. It appears that if you upgrade to MacOS 14.4.1 the problem should be solved:
https://blogs.oracle.com/java/post/java-on-macos-14-4#:~:text=An%20issue%20introduced%20by%20macOS,the%20signal%20and%20continue%20execution.

Hi! Thanks for this reply - and indeed upgrading my MacOS did the trick! I'm now using MacOS Sequoia 15.1 for future reference! Thanks everyone!

1 Like

This topic was automatically closed 7 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.