2013-06-06 2 views
2

한 번에 둘 이상의 결과를 얻으려면 Rcaller를 어떻게 사용합니까? 예를 들어, 나는 ... 나는 caller.getParser().getNames().size()을 사용할 수 있습니다, 그리고 egfunctionrcaller가 runAndReturnResult로 결과를 얻는 방법

code.addRCode("data<-read.table(\""+ "/home/yo/Documents/Book1.csv"+ "\", header=TRUE,sep=\"\t\")"); 
caller.setRCode(code); 
caller.runAndReturnResult("data"); 

를 사용하지만 summary(data$pH)를 실행하려면, 어떻게해야합니까? 이전에 코드를 추가?를하는 경우, "호출자"는 어느 것입니까? 도와 주신 분께 감사드립니다.

답변

1

사용 목록을 사용 RCaller 결과 얻을 수있는 예를 들어 당신이 rcaller.runAndReturnResult (결과) 호출 한 후

result <- list(a=c(1,2,3), b=3.6, c=5) 

의 목록을 얼마나 demostrate A, B 및 C는 변수 액세스 위아에게

double[] a = rcaller.getParser().getAsDoubleArray("a"); 

또는

있다
int c = rcaller.getParser().getAsIntegerArray("c")[0]; 

getNames() 메소드를 사용하면 '결과'목록에도 포함 된 이름을 가져올 수 있습니다.

summary()를 사용하면 아무 것도 변경되지 않습니다. 당신이

ols <- lm (y ~ x + z, data=mydata) 

같은 R의 LM() 호출을 다음

detailed <- summary(ols) 

이이 작품의 반환 값으로, 또한 목록입니다 가정(). 당신은

double[] residuals = rcaller.getParser().getAsDoubleArray("residuals"); 

double rsquared = rcaller.getParser().getAsDoubleArray("r.squared")[0]; 

아무것도 요약 한 후 변경()를 사용하지 않는이리스트의 요소에 액세스 할 수 있습니다. 돌아 가기 목록을 반환하지 않는 코드

code.addRCode("data<-read.table(\""+ "/home/yo/Documents/Book1.csv"+ "\", header=TRUE,sep=\"\t\")"); 
caller.setRCode(code); 
caller.runAndReturnResult("data"); 

에, 당신은 오히려 결국

RCode code = new RCode(); 
code.addRCode("myresult <- list(res1=data$pH, res2=data$anotherVector)"); 
rcaller.setRCode(code); 
caller.runAndReturnResult("myresult"); 

,

double[] pH = caller.getParser().getAsDoubleArray(pH); 

의 pH 변수를 반환를 입력 할 수 있습니다. 자세한 내용은

, 공식 블로그를 방문 here