R 集成,R 提交文件问题你好,
更新:我找到了在评论中发布的解决方法。
此 JSL 脚本运行没有任何问题(我在 Windows 10 Pro 64 位下使用 JMP 16.0.0 (512257))并生成预期的 png 输出格图在 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;如果我尝试使用完全相同的 R 代码直接调用 R 脚本,则会失败并显示错误消息“获取 ''png”的数据失败”。
这是 JSL 脚本:
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;
这个简化的 JSL 脚本是我的第一次尝试,也失败并显示相同的错误代码:
R Init();
R Submit File( "C:\Users\xxx\R_projects\JMP\R_JPM_integration_1.R" );
R Get Graphics( png );
R Term();
这是我用于此测试的简单 R 脚本:
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)
这与第一个脚本中的 R 代码相同。
R Submit File 调用有问题吗? 我缺少什么?
我更愿意使用R 提交文件因为它节省了打字工作。
自动化和脚本编写数据混合和清理视窗回复:R 集成,R 提交文件问题我不需要视窗()函数调用。 只需通过调用显式绘制阴谋功能足够了!
我确实发现 JMP 错误消息( “获取“png”数据失败” )一旦我使用就会消失视窗R 中的函数调用 我最终得到一个空窗口,因为没有明确绘制任何内容。
下面的代码与 JSL scipt 结合使用可以很好地工作R 提交文件。
library(dplyr)
library(ggplot2)
library(palmerpenguins)
p <- ggplot(data = penguins, aes(x = bill_length_mm, y = flipper_length_mm, colour = species)) +
geom_point() +
facet_wrap(. ~ island, nrow = 3)
plot(p)
回复:R 集成,R 提交文件问题我找到了一种解决方法,即强制 R 打开图形窗口并将图形显式绘制到该窗口:
library(dplyr)
library(ggplot2)
library(palmerpenguins)
windows(800,600)
p <- ggplot(data = penguins, aes(x = bill_length_mm, y = flipper_length_mm, colour = species)) +
geom_point() +
facet_wrap(. ~ island, nrow = 3)
plot(p)
我现在需要担心地块大小,但这是可以接受的。 以下是带有 JMP 图形窗口的脚本的屏幕截图:

回复:R 集成,R 提交文件问题谢谢!
的确,提交工作得很好,请参阅下面的代码。
不过,我想确定如何制作R 提交文件工作,因为它可以防止复制(可能很大)R 脚本。
您对原因的评估R 提交文件不起作用听起来似乎有道理,但需要 SAS/JMP 专家来确认。
LoadExprs = Expr(
InitR = Expr(
R Init();
);
RunR = Expr(
R Submit ( "
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)
" );
);
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;
回复:R 集成,R 提交文件问题我认为使用 R Submit File 时,绘图不会写入控制台(我可能是错的,我还没有进行足够的挖掘来确定)。我通过将 R 文件作为文本读取到 JMP 中,然后使用 R Submit 提交来解决了这个问题。
回复:R 集成,R 提交文件问题我在 Windows 10 64 位上运行的 16.2 和 17.0 下运行了您的代码,并得到了在 JMP 下运行时,“获取“png”的数据失败”。