R interface in JMPHello,
I wrote a code in R that I want to run into JMP. Here is the code :
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();
Then when I run it I got two issues:
Firstly I have an error from these lines :
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)
which says :
Error: Function boundingbox called with 2 unrecognised arguments
In addition: Warning message:
2 points were rejected as lying outside the specified window
In fact when I change 40 into 0 it works because all my points are in my window, but when I run the code on R the fact that all my points are not in the window is not an issue. And if I run the previous code in R it works. So I don't understand why I got a warning message in JMP but not in R.
The second issue is when I want to export my data, JMP don't want to extract my data frame and I don't understand why. I use this code :
ResidJMP = R Get(Distribution);
ResidJMP << New Data View;
R term();
In fact I want to return a data table in JMP and after I want to use it as the main data table.
Data TableOtherScriptingWindowsRe: R interface in JMPHello,
For a basic example,
R Init(); // Initiate R connection
dt = Open(“$SAMPLE_DATA/Big Class.jmp”,invisible);
R Send(dt);
the call of column should be done on the following way:
R Submit("
print(dt['weight'])
//b<-dt['weight']/dt['height']
");
instead of
R Submit("
print(dt$weight)
//b<-dt['weight']/dt['height']
");
I think it should change the output of your first problem.
Re: R interface in JMPWhen I apply this to my data it says that the columns I used aren't numeric, then when I use as.numeric() function it says : 'list' object cannot be coerced to type 'double'. This problem doesn't appeared with the $ call. There are so many issues here unfortunately
Re: R interface in JMPYou can use a JMP data table as a data frame in R. The R Send() function automatically converts one data structure into the other. Here is a simple example:
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
So I suspect that there is a problem with the R code (function arguments), or the nature of the variables in the data frame. After you make sure that your function call is correct, try printing the data table from R to see if everything transferred as expected.
Re: R interface in JMPWhen I use this code on 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)
It works good. In fact it works good in JMP if I use this window :
fenn<-owin(xrange=c(0,760), yrange=c(0,160), poly=NULL, mask=NULL, units=NULL)
Because all my (x,y) points are in the window, the problem comes out when I put the window I want. But in R there is no problem of window.
But if there is a problem with the variables it shouldn't work with an other window and this is what I don't understand.
Maybe there is something I don't understand in your comment but I don't find what could be the error. When I print it on JMP from R I have the good data frame. I'm lost for sure
Re: R interface in JMPI try to use R Submit File() function so I can use the exact same code. But I have the same error on the jmp code that I don't have in R. This is the error that I need resolve. I try so much things and also don't understand why it appears.
Error: Function boundingbox called with 2 unrecognised arguments