Hi,
Update: I found a workaround which I posted in the comments.
This JSL script runs without any problems (I am using JMP 16.0.0 (512257) under Windows 10 Pro 64 bit) and generates the expected png output from ggplot in JMP:
LoadExprs = Expr(
InitR = Expr(
R Init();
R Submit( "
library(dplyr)
library(ggplot2)
library(palmerpenguins)
" );
);
MakePlot = Expr(
R Submit(
Eval Insert(
"\[
ggplot(data = penguins, aes(x = bill_length_mm, y = flipper_length_mm, colour = species)) +
geom_point() +
facet_wrap(. ~ island, nrow = 3)
]\
"
);
);
);
CapturePlot = Expr(
JMP_plot = R Get Graphics( png );
New Window( "Imported Plot", Picture Box( JMP_Plot ) );
);
RunClose = Expr(
R Term(); //Close r connection
);
);
LoadExprs;
InitR;
MakePlot;
CapturePlot;
RunClose;
If I try to call the R script directly, with the exact same R code, it fails with the error message "Get data for ''png" failed".
Here's the JSL script:
LoadExprs = Expr(
InitR = Expr(
R Init();
);
RunR = Expr(
R Submit File( "C:\Users\xxx\R_projects\JMP\R_JPM_integration_1.R" );
);
CapturePlot = Expr(
JMP_plot = R Get Graphics( png );
New Window( "Imported Plot", Picture Box( JMP_Plot ) );
);
RunClose = Expr(
R Term(); //Close r connection
);
);
LoadExprs;
InitR;
RunR;
CapturePlot;
RunClose;
This simplified JSL script, my first attempt, also fails with the same error code:
R Init();
R Submit File( "C:\Users\xxx\R_projects\JMP\R_JPM_integration_1.R" );
R Get Graphics( png );
R Term();
And here's the simple R-script I use for this test:
library(dplyr)
library(ggplot2)
library(palmerpenguins)
ggplot(data = penguins, aes(x = bill_length_mm, y = flipper_length_mm, colour = species)) +
geom_point() +
facet_wrap(. ~ island, nrow = 3)
Which is identical to the R code in the first script.
Is there a problem with the R Submit File call? What am I missing?
I would prefer to use R Submit File as it saves typing work.