JMP 中的 R 接口你好,
我在 R 中編寫了一段代碼,希望在 JMP 中運行。 這是代碼:
R init();
//send data to R
R Send(dt);
R submit("
library(spatstat)
#creation fenetre
fenn<-owin(xrange=c(40,760), yrange=c(40,160), poly=NULL, mask=NULL, units=NULL)
ppp<-ppp(x=dt$XM,y=dt$YM,window=fenn)
print(quadratcount(ppp,nx=6,ny=3)
Q<-quadrat.test.ppp(ppp,nx=6,ny=3)
a<-cdf.test(ppp,'x')
D=0
if(a[[2]] & Q[[3]] < 0.1 ){
D=0}else {D=1}
Distribution=as.data.frame(rep(c(D),nrow(dt)))
class(Distribution)
print(a)
");
R term();
然後當我運行它時,我遇到了兩個問題:
首先,我從這些行中得到一個錯誤:
fenn<-owin(xrange=c(40,760), yrange=c(40,160), poly=NULL, mask=NULL, units=NULL)
ppp<-ppp(x=dt$XM,y=dt$YM,window=fenn)
其中說:
錯誤:使用 2 個無法識別的參數調用函數邊界框
另外:警告消息:
2 個點因位於指定窗口之外而被拒絕
事實上,當我將 40 更改為 0 時,它會起作用,因為我的所有點都在我的窗口中,但是當我在 R 上運行代碼時,我的所有點都不在窗口中這一事實並不是問題。 如果我在 R 中運行之前的代碼,它就會起作用。 所以我不明白為什麼我在 JMP 中收到警告消息,但在 R 中卻沒有。
第二個問題是當我想導出數據時,JMP 不想提取我的數據框,我不明白為什麼。 我使用這個代碼:
ResidJMP = R Get(Distribution);
ResidJMP << New Data View;
R term();
事實上我想在JMP中返回一個數據表,然後我想用它作為主數據表。
大規模定制視窗回复:JMP 中的 R 接口錯誤有解決辦法嗎?
Error in if (is.na(datam)) { : the condition has length > 1我有同樣的問題。
回复:JMP 中的 R 接口我建議您聯繫 JMP 技術支持( support@jmp.com )尋求解決此問題的幫助。
回复:JMP 中的 R 接口現在我的主要問題是從 R 導出數據框。 我的例子和我的數據有同樣的錯誤。
Erreur : Error in if (is.na(datam)) { : the condition has length > 1
Unexpected errors occurred while attempting to transfer the data.我檢查我的 R get() 是否在 data.frame 上。 這是我的代碼:
Treat=Open( "C:\Users\GROUSD01\Desktop\CréationcodeMPPT\Results 4.jmp" );
R init();
//send data to R
R Send(Treat);
R submit("library(spatstat)
round(Treat$XM)
round(Treat$YM)
XM<-Treat$XM
YM<-Treat$YM
test<-as.data.frame(cbind(XM,YM))
test2<-data.frame()
for (i in 1:nrow(test)){
if(test[i,2]>39){
test2<-rbind(test2,test[i,1:2])}}
fenn<-owin(xrange=c(40,760), yrange=c(40,160), poly=NULL, mask=NULL, units=NULL)
#creation point pattern
ppp<-ppp(x=test2$XM,y=test2$YM,window=fenn)
print(ppp)
plot(quadratcount(ppp,nx=6,ny=3))
Q<-quadrat.test.ppp(ppp,nx=6,ny=3)
print(Q)
a<-cdf.test(ppp,'x')
paste('Ma pvalue du KS test ', format(a[[2]], digits=3))
D=character()
if(a[[2]] & Q[[3]] < 0.1 ){
D='Distribution Non-Uniforme'}else {D='Distribution Uniforme'}
Distribution<-(rep(c(D),length(Treat$XM)))
Treat<-cbind(Treat,Distribution)
");
R Get(Treat)<<New Data View
R term();但我嘗試了很多不同的事情以獲得相同的結果
回复:JMP 中的 R 接口你的例子有效我在日誌中有這個:

對於你的第二個問題,我不確定我是否理解得很好。 但我嘗試使用 send() 命令將 JMP 數據表發送到 R,然後將其打印在日誌中。 對於您的示例,它看起來像這樣:

在我的示例中,我在日誌中得到了以下內容:

我的桌子看起來像這樣:

回复:JMP 中的 R 接口你嘗試過我的簡單例子嗎? 有效嗎? 您在 JMP 日誌中看到什麼?
您是否嘗試將 JMP 數據表發送到 R 並在 R 中打印? 該數據框與數據表匹配嗎?
回复:JMP 中的 R 接口我嘗試使用 R Submit File() 函數,這樣我就可以使用完全相同的代碼。 但我在 jmp 代碼上遇到了與 R 中沒有的相同錯誤。 這是我需要解決的錯誤。 我嘗試了很多事情,也不明白為什麼會出現。
Error: Function boundingbox called with 2 unrecognised arguments
回复:JMP 中的 R 接口當我在 R 上使用這段代碼時
library(spatstat)
data<-read.("Results.csv")
#creation fenetre
fenn<-owin(xrange=c(40,760), yrange=c(40,160), poly=NULL, mask=NULL, units=NULL)
#creation point pattern
ppp<-ppp(x=data$XM,y=data$YM,window=fenn)
plot(ppp)
summary(ppp)
#test quadrat
quadratcount(ppp,nx=6,ny=3)
Q<-quadrat.test.ppp(ppp,nx=6,ny=3)
paste("Ma pvalue du quadrat test ", format(Q[[3]], scientific=TRUE, digits=3))
#test ks
a<-kstest(ppp,'x')
paste("Ma pvalue du KS test ", format(a[[2]], scientific=TRUE, digits=3))
D=character()
if(a[[2]] & Q[[3]] < 0.1 ){
D="Distribution Non-Uniforme"}else {D="Distribution Uniforme"}
Distribution<-rep(c(D),length(XM))
dt<-cbind(dt,Distribution)
效果很好。 事實上,如果我使用此窗口,它在 JMP 中效果很好:
fenn<-owin(xrange=c(0,760), yrange=c(0,160), poly=NULL, mask=NULL, units=NULL)
因為我所有的(x,y)點都在窗口中,所以當我放置我想要的窗口時問題就出現了。 但在R中不存在窗口問題。
但是,如果變量有問題,它不應該與其他窗口一起使用,這就是我不明白的地方。
也許您的評論中有一些我不明白的地方,但我找不到可能的錯誤。 當我在 RI 的 JMP 上打印它時,有良好的數據框。 我肯定迷路了
回复:JMP 中的 R 接口您可以使用 JMP 數據表作為 R 中的數據框。 R Send() 函數自動將一種數據結構轉換為另一種數據結構。 這是一個簡單的例子:
Names Default to Here( 1 );
// make sure JMP can find the desired installed version of R
Set Environment Variable( "R_HOME", "C:\Program Files\R\R-4.1.3" );
// use regression example from JMP Sample Data Folder
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// use standard linear model function with data frame
R Init( );
R Send( dt );
R Submit(
"fit <- lm( dt$weight~dt$height )
print( fit )"
);
R Term();
// examine results in Log
所以我懷疑R代碼(函數參數)有問題,或者數據框中變量的性質有問題。 確保函數調用正確後,嘗試從 R 打印數據表,看看是否所有內容都按預期傳輸。
回复:JMP 中的 R 接口當我將此應用於我的數據時,它說我使用的列不是數字,然後當我使用 as.numeric() 函數時,它說:“list”對像不能被強制輸入“double”。 $ 調用不會出現此問題。 不幸的是這裡有很多問題
回复:JMP 中的 R 接口你好,
舉一個基本的例子,
R Init(); // Initiate R connection
dt = Open(“$SAMPLE_DATA/Big Class.jmp”,invisible);
R Send(dt);
列的調用應按以下方式完成:
R Submit("
print(dt['weight'])
//b<-dt['weight']/dt['height']
");
代替
R Submit("
print(dt$weight)
//b<-dt['weight']/dt['height']
");
我認為它應該改變你的第一個問題的輸出。