在RStudio中执行R语句,得到结果如下:
结果一:
> eperson(economic)
[[1]]
[1] "主成份分析结果为"
[[2]]
Importance of components:
Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7
Standard deviation 2.1124391 1.1491308 0.9331551 0.50448791 0.2699638 0.137595030 0
Proportion of Variance 0.6374856 0.1886431 0.1243969 0.03635829 0.0104115 0.002704627 0
Cumulative Proportion 0.6374856 0.8261287 0.9505256 0.98688388 0.9972954 1.000000000 1
Loadings:
Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7
x1 -0.446 0.127 0.138 0.431 0.599 0.241 -0.404
x2 -0.467 0.268 0.837
x3 -0.445 0.146 -0.243 -0.671 0.451 -0.260
x4 -0.377 -0.377 0.168 -0.763 0.236 0.223
x5 -0.257 -0.297 -0.819 0.162 -0.382
x6 -0.418 0.280 0.337 -0.137 -0.196 -0.730 -0.208
x7 0.808 -0.319 -0.375 0.265 0.150
[[3]]
[1] "综合得分和经济人口承载力为"
[[4]]
年份 指数 承载人口
1 2006 2.2589596 178.29831
2 2007 1.9662692 155.19644
3 2008 1.6925468 133.59169
4 2009 0.2778931 21.93393
5 2010 0.8682956 68.53405
6 2011 1.8017713 142.21272
7 2012 2.9307567 231.32285
现在我在java里调用R语句,代码如下:
xp=c.eval("eperson(economic)");//java调用R语句
System.out.println("----eperson(economic).asList()-----");
for(int i=0;i<xp.asInteger();i++){//试图循环打印R语句执行结果
System.out.println(xp.asStrings()[i]);
}
java调用R语句得到的结果如下:
结果二:
----eperson(economic).asList()-----
org.rosuda.REngine.REXPString@2420badf[1]
org.rosuda.REngine.REXPGenericVector@60cc9900+[9]named
org.rosuda.REngine.REXPString@185100a6[1]
org.rosuda.REngine.REXPGenericVector@6e019ec2+[3]named
结果二并不是我想要的,我想在结果二里得到结果一,并显示在网页上,请问该如何解决?
直接调用R里面的ggplot+plotly+shiny 或者你如果是用java的话可以直接写一个js