[SPARK-13472] [SPARKR] Fix unstable Kmeans test in R
[SPARK-13472] [SPARKR] Fix unstable Kmeans test in R

JIRA: https://issues.apache.org/jira/browse/SPARK-13472

## What changes were proposed in this pull request?

One Kmeans test in R is unstable and sometimes fails. We should fix it.

## How was this patch tested?

Unit test is modified in this PR.

Author: Liang-Chi Hsieh <viirya@gmail.com>

Closes #11345 from viirya/fix-kmeans-r-test and squashes the following commits:

f959f61 [Liang-Chi Hsieh] Sort resulted clusters.

ron8hu/spark,skonto/spark,kiszk/spark,jrshust/spark,someorz/spark,loneknightpy/spark,Aegeaner/spark,publicRoman/spark,wzhfy/spark,zuotingbing/spark,liyichao/spark,bdrillard/spark,brad-kaiser/spark,facaiy/spark,ddna1021/spark,rezasafi/spark,lvdongr/spark,MLnick/spark,hvanhovell/spark,poffuomo/spark,kiszk/spark,wangmiao1981/spark,aosagie/spark,bdrillard/spark,rednaxelafx/apache-spark,nchammas/spark,apache/spark,ibm-research-ireland/sparkoscope,pgandhi999/spark,xuanyuanking/spark,taroplus/spark,kiszk/spark,tengpeng/spark,alunarbeach/spark,eyalfa/spark,guoxiaolongzte/spark,dongjoon-hyun/spark,sahilTakiar/spark,narahari92/spark,narahari92/spark,apache-spark-on-k8s/spark,guoxiaolongzte/spark,zzcclp/spark,adrian-ionescu/apache-spark,bravo-zhang/spark,aokolnychyi/spark,vinodkc/spark,minixalpha/spark,wangyum/spark,apache-spark-on-k8s/spark,janewangfb/spark,Panos-Bletsos/spark-cost-model-optimizer,ptkool/spark,pgandhi999/spark,SnappyDataInc/spark,icexelloss/spark,mike0sv/spark,cin/spark,MLnick/spark,jkbradley/spark,witgo/spark,kissmetrics/spark,dongjoon-hyun/spark,dhruve/spark,Panos-Bletsos/spark-cost-model-optimizer,rekhajoshm/spark,yanboliang/spark,nilsgrabbert/spark,ajaysaini725/spark,map222/spark,JerryLead/spark,WindCanDie/spark,janewangfb/spark,srowen/spark,highfei2011/spark,JoshRosen/spark,xuanyuanking/spark,hvanhovell/spark,tengpeng/spark,dbtsai/spark,aosagie/spark,ajaysaini725/spark,vinodkc/spark,kevinyu98/spark,Aegeaner/spark,mahak/spark,maropu/spark,setjet/spark,loneknightpy/spark,ueshin/apache-spark,wangmiao1981/spark,szhem/spark,dhruve/spark,JoshRosen/spark,rezasafi/spark,pgandhi999/spark,highfei2011/spark,caneGuy/spark,LantaoJin/spark,JoshRosen/spark,dbtsai/spark,techaddict/spark,nilsgrabbert/spark,aokolnychyi/spark,icexelloss/spark,zzcclp/spark,HyukjinKwon/spark,UndeadBaneGitHub/spark,zuotingbing/spark,SHASHANKB/spark,sahilTakiar/spark,SHASHANKB/spark,brad-kaiser/spark,nlalevee/spark,wzhfy/spark,tengpeng/spark,goldmedal/spark,metamx/spark,WeichenXu123/spark,patrick-nicholson/spark,sureshthalamati/spark,brad-kaiser/spark,debugger87/spark,jiangxb1987/spark,ueshin/apache-spark,nilsgrabbert/spark,brad-kaiser/spark,zuotingbing/spark,mdespriee/spark,michalsenkyr/spark,loneknightpy/spark,sahilTakiar/spark,aray/spark,goldmedal/spark,wangyum/spark,xuanyuanking/spark,panfengfeng/spark,jianran/spark,metamx/spark,SHASHANKB/spark,guoxiaolongzte/spark,dhruve/spark,shubhamchopra/spark,big-pegasus/spark,ron8hu/spark,jkbradley/spark,JerryLead/spark,joseph-torres/spark,andrewor14/spark,srowen/spark,kiszk/spark,zzcclp/spark,vinodkc/spark,michalsenkyr/spark,michalsenkyr/spark,big-pegasus/spark,nlalevee/spark,zhouyejoe/spark,Aegeaner/spark,bravo-zhang/spark,saltstar/spark,byakuinss/spark,zuotingbing/spark,ioana-delaney/spark,UndeadBaneGitHub/spark,BryanCutler/spark,zhouyejoe/spark,sureshthalamati/spark,yanboliang/spark,tengpeng/spark,aray/spark,xflin/spark,stanzhai/spark,milliman/spark,jiangxb1987/spark,kimoonkim/spark,bOOm-X/spark,milliman/spark,brad-kaiser/spark,wzhfy/spark,shuangshuangwang/spark,shaneknapp/spark,michalsenkyr/spark,bdrillard/spark,debugger87/spark,mzl9039/spark,Aegeaner/spark,JoshRosen/spark,ConeyLiu/spark,actuaryzhang/spark,mike0sv/spark,MLnick/spark,markhamstra/spark,ajaysaini725/spark,huang1900/spark,janewangfb/spark,ahnqirage/spark,SnappyDataInc/spark,byakuinss/spark,witgo/spark,publicRoman/spark,milliman/spark,spark-test/spark,ron8hu/spark,LantaoJin/spark,map222/spark,michalsenkyr/spark,big-pegasus/spark,adrian-ionescu/apache-spark,mzl9039/spark,hvanhovell/spark,1haodian/spark,alunarbeach/spark,jlopezmalla/spark,michalsenkyr/spark,jlopezmalla/spark,huang1900/spark,alunarbeach/spark,yanboliang/spark,saturday-shi/spark,ueshin/apache-spark,skonto/spark,publicRoman/spark,esi-mineset/spark,SnappyDataInc/spark,eyalfa/spark,kimoonkim/spark,shuangshuangwang/spark,SHASHANKB/spark,patrick-nicholson/spark,akopich/spark,mahak/spark,rikima/spark,setjet/spark,liyichao/spark,mdespriee/spark,LantaoJin/spark,SHASHANKB/spark,saturday-shi/spark,debugger87/spark,holdenk/spark,cin/spark,mike0sv/spark,vinodkc/spark,lvdongr/spark,UndeadBaneGitHub/spark,ddna1021/spark,gioenn/xSpark,ajaysaini725/spark,shuangshuangwang/spark,caneGuy/spark,janewangfb/spark,eyalfa/spark,aokolnychyi/spark,debugger87/spark,big-pegasus/spark,cloud-fan/spark,JerryLead/spark,nchammas/spark,aray/spark,saturday-shi/spark,aosagie/spark,rekhajoshm/spark,ddna1021/spark,adrian-ionescu/apache-spark,mdespriee/spark,vinodkc/spark,saltstar/spark,zzcclp/spark,jkbradley/spark,taroplus/spark,tejasapatil/spark,LantaoJin/spark,JoshRosen/spark,adrian-ionescu/apache-spark,mahak/spark,minixalpha/spark,rekhajoshm/spark,kevinyu98/spark,dbtsai/spark,mdespriee/spark,andrewor14/spark,gioenn/xSpark,goldmedal/spark,kiszk/spark,ptkool/spark,kissmetrics/spark,HyukjinKwon/spark,stanzhai/spark,LantaoJin/spark,cloud-fan/spark,tejasapatil/spark,michalsenkyr/spark,huang1900/spark,huang1900/spark,gioenn/xSpark,markhamstra/spark,Panos-Bletsos/spark-cost-model-optimizer,gengliangwang/spark,SnappyDataInc/spark,skonto/spark,JerryLead/spark,HyukjinKwon/spark,caneGuy/spark,rikima/spark,hhbyyh/spark,zzcclp/spark,rikima/spark,1haodian/spark,guoxiaolongzte/spark,loneknightpy/spark,szhem/spark,Panos-Bletsos/spark-cost-model-optimizer,andrewor14/spark,ptkool/spark,jrshust/spark,1haodian/spark,joseph-torres/spark,metamx/spark,aosagie/spark,poffuomo/spark,ahnqirage/spark,jiangxb1987/spark,pgandhi999/spark,someorz/spark,aosagie/spark,sureshthalamati/spark,shuangshuangwang/spark,sahilTakiar/spark,kevinyu98/spark,eyalfa/spark,panfengfeng/spark,JoshRosen/spark,hhbyyh/spark,dhruve/spark,map222/spark,someorz/spark,shuangshuangwang/spark,WeichenXu123/spark,rikima/spark,rekhajoshm/spark,jlopezmalla/spark,goldmedal/spark,SnappyDataInc/spark,hhbyyh/spark,patrick-nicholson/spark,chuckchen/spark,facaiy/spark,map222/spark,techaddict/spark,hhbyyh/spark,alunarbeach/spark,loneknightpy/spark,bOOm-X/spark,poffuomo/spark,ddna1021/spark,publicRoman/spark,tejasapatil/spark,ahnqirage/spark,gengliangwang/spark,witgo/spark,xflin/spark,big-pegasus/spark,nilsgrabbert/spark,lvdongr/spark,darionyaphet/spark,rednaxelafx/apache-spark,lvdongr/spark,rekhajoshm/spark,zero323/spark,eyalfa/spark,tengpeng/spark,Aegeaner/spark,ericvandenbergfb/spark,stanzhai/spark,alunarbeach/spark,SnappyDataInc/spark,rednaxelafx/apache-spark,patrick-nicholson/spark,jkbradley/spark,xuanyuanking/spark,ron8hu/spark,kevinyu98/spark,mzl9039/spark,MLnick/spark,milliman/spark,saltstar/spark,kimoonkim/spark,liutang123/spark,vinodkc/spark,jkbradley/spark,dhruve/spark,apache-spark-on-k8s/spark,zuotingbing/spark,matthewfranglen/spark,ahnqirage/spark,rikima/spark,saltstar/spark,maropu/spark,WindCanDie/spark,facaiy/spark,lxsmnv/spark,jrshust/spark,metamx/spark,someorz/spark,kevinyu98/spark,yanboliang/spark,ahnqirage/spark,dbtsai/spark,joseph-torres/spark,dhruve/spark,sachintyagi22/spark,nilsgrabbert/spark,1haodian/spark,zero323/spark,taroplus/spark,rezasafi/spark,byakuinss/spark,debugger87/spark,srowen/spark,actuaryzhang/spark,big-pegasus/spark,WindCanDie/spark,guoxiaolongzte/spark,wangyum/spark,bravo-zhang/spark,hhbyyh/spark,xflin/spark,apache-spark-on-k8s/spark,ericvandenbergfb/spark,caneGuy/spark,spark-test/spark,holdenk/spark,kevinyu98/spark,xflin/spark,aokolnychyi/spark,ibm-research-ireland/sparkoscope,liutang123/spark,apache/spark,janewangfb/spark,mzl9039/spark,sachintyagi22/spark,mike0sv/spark,narahari92/spark,patrick-nicholson/spark,guoxiaolongzte/spark,MLnick/spark,jrshust/spark,dhruve/spark,sahilTakiar/spark,tejasapatil/spark,wzhfy/spark,mahak/spark,ConeyLiu/spark,kevinyu98/spark,ConeyLiu/spark,hhbyyh/spark,wzhfy/spark,adrian-ionescu/apache-spark,xuanyuanking/spark,ajaysaini725/spark,ibm-research-ireland/sparkoscope,ioana-delaney/spark,UndeadBaneGitHub/spark,1haodian/spark,skonto/spark,ptkool/spark,panfengfeng/spark,ajaysaini725/spark,lvdongr/spark,1haodian/spark,kiszk/spark,ibm-research-ireland/sparkoscope,witgo/spark,rikima/spark,gengliangwang/spark,skonto/spark,bdrillard/spark,zhouyejoe/spark,liutang123/spark,tejasapatil/spark,dbtsai/spark,shaneknapp/spark,jiangxb1987/spark,spark-test/spark,ahnqirage/spark,map222/spark,jlopezmalla/spark,markhamstra/spark,nlalevee/spark,BryanCutler/spark,bdrillard/spark,pgandhi999/spark,akopich/spark,dongjoon-hyun/spark,WindCanDie/spark,chuckchen/spark,byakuinss/spark,szhem/spark,holdenk/spark,xuanyuanking/spark,icexelloss/spark,stanzhai/spark,sureshthalamati/spark,debugger87/spark,aray/spark,bdrillard/spark,WindCanDie/spark,srowen/spark,cin/spark,guoxiaolongzte/spark,zzcclp/spark,liyichao/spark,aokolnychyi/spark,facaiy/spark,mdespriee/spark,caneGuy/spark,WeichenXu123/spark,caneGuy/spark,rekhajoshm/spark,gengliangwang/spark,ptkool/spark,kimoonkim/spark,jianran/spark,milliman/spark,shuangshuangwang/spark,mike0sv/spark,ericvandenbergfb/spark,ConeyLiu/spark,icexelloss/spark,aray/spark,mdespriee/spark,maropu/spark,ron8hu/spark,map222/spark,JerryLead/spark,minixalpha/spark,bdrillard/spark,poffuomo/spark,shaneknapp/spark,markhamstra/spark,akopich/spark,saturday-shi/spark,cin/spark,techaddict/spark,ddna1021/spark,zhouyejoe/spark,someorz/spark,bravo-zhang/spark,dbtsai/spark,ericvandenbergfb/spark,saturday-shi/spark,jrshust/spark,zero323/spark,nilsgrabbert/spark,tejasapatil/spark,JoshRosen/spark,markhamstra/spark,huang1900/spark,gioenn/xSpark,sachintyagi22/spark,skonto/spark,BryanCutler/spark,liyichao/spark,nchammas/spark,liyichao/spark,mzl9039/spark,shaneknapp/spark,ueshin/apache-spark,eyalfa/spark,akopich/spark,esi-mineset/spark,ericvandenbergfb/spark,yanboliang/spark,bOOm-X/spark,mahak/spark,1haodian/spark,hvanhovell/spark,minixalpha/spark,yanboliang/spark,szhem/spark,apache/spark,jianran/spark,srowen/spark,mahak/spark,cin/spark,chuckchen/spark,milliman/spark,icexelloss/spark,BryanCutler/spark,sureshthalamati/spark,mike0sv/spark,ioana-delaney/spark,techaddict/spark,esi-mineset/spark,joseph-torres/spark,apache/spark,maropu/spark,panfengfeng/spark,liutang123/spark,saturday-shi/spark,taroplus/spark,saltstar/spark,ueshin/apache-spark,aray/spark,darionyaphet/spark,gengliangwang/spark,szhem/spark,mahak/spark,tengpeng/spark,wangmiao1981/spark,jianran/spark,esi-mineset/spark,setjet/spark,chuckchen/spark,apache/spark,setjet/spark,saturday-shi/spark,stanzhai/spark,SHASHANKB/spark,rikima/spark,szhem/spark,jianran/spark,skonto/spark,szhem/spark,map222/spark,alunarbeach/spark,srowen/spark,dongjoon-hyun/spark,LantaoJin/spark,janewangfb/spark,liyichao/spark,poffuomo/spark,Aegeaner/spark,mzl9039/spark,WeichenXu123/spark,lxsmnv/spark,rednaxelafx/apache-spark,holdenk/spark,adrian-ionescu/apache-spark,dongjoon-hyun/spark,kimoonkim/spark,jrshust/spark,JerryLead/spark,joseph-torres/spark,jkbradley/spark,BryanCutler/spark,ericvandenbergfb/spark,brad-kaiser/spark,WeichenXu123/spark,metamx/spark,byakuinss/spark,apache-spark-on-k8s/spark,sachintyagi22/spark,WeichenXu123/spark,MLnick/spark,ioana-delaney/spark,markhamstra/spark,nchammas/spark,jiangxb1987/spark,gengliangwang/spark,actuaryzhang/spark,dongjoon-hyun/spark,kissmetrics/spark,BryanCutler/spark,gengliangwang/spark,minixalpha/spark,xuanyuanking/spark,sureshthalamati/spark,aosagie/spark,lxsmnv/spark,highfei2011/spark,shubhamchopra/spark,cloud-fan/spark,jlopezmalla/spark,sahilTakiar/spark,goldmedal/spark,kimoonkim/spark,hvanhovell/spark,cin/spark,patrick-nicholson/spark,debugger87/spark,zhouyejoe/spark,andrewor14/spark,taroplus/spark,UndeadBaneGitHub/spark,nlalevee/spark,gioenn/xSpark,aokolnychyi/spark,ioana-delaney/spark,publicRoman/spark,zhouyejoe/spark,gioenn/xSpark,rednaxelafx/apache-spark,rezasafi/spark,narahari92/spark,esi-mineset/spark,dbtsai/spark,ioana-delaney/spark,kimoonkim/spark,facaiy/spark,shuangshuangwang/spark,jiangxb1987/spark,publicRoman/spark,saltstar/spark,holdenk/spark,rezasafi/spark,wzhfy/spark,JerryLead/spark,shubhamchopra/spark,zero323/spark,akopich/spark,setjet/spark,ioana-delaney/spark,UndeadBaneGitHub/spark,kissmetrics/spark,minixalpha/spark,publicRoman/spark,facaiy/spark,minixalpha/spark,WindCanDie/spark,Panos-Bletsos/spark-cost-model-optimizer,darionyaphet/spark,holdenk/spark,liutang123/spark,panfengfeng/spark,zzcclp/spark,techaddict/spark,akopich/spark,byakuinss/spark,milliman/spark,bOOm-X/spark,actuaryzhang/spark,liutang123/spark,kissmetrics/spark,chuckchen/spark,Aegeaner/spark,mike0sv/spark,zuotingbing/spark,shubhamchopra/spark,tejasapatil/spark,darionyaphet/spark,andrewor14/spark,goldmedal/spark,loneknightpy/spark,wangmiao1981/spark,ahnqirage/spark,shubhamchopra/spark,liutang123/spark,holdenk/spark,witgo/spark,darionyaphet/spark,cin/spark,jiangxb1987/spark,wangyum/spark,metamx/spark,huang1900/spark,metamx/spark,kissmetrics/spark,techaddict/spark,brad-kaiser/spark,lvdongr/spark,nchammas/spark,adrian-ionescu/apache-spark,joseph-torres/spark,techaddict/spark,setjet/spark,wangyum/spark,caneGuy/spark,taroplus/spark,jlopezmalla/spark,yanboliang/spark,zero323/spark,goldmedal/spark,poffuomo/spark,rezasafi/spark,ajaysaini725/spark,BryanCutler/spark,lxsmnv/spark,bOOm-X/spark,xflin/spark,darionyaphet/spark,stanzhai/spark,huang1900/spark,maropu/spark,SnappyDataInc/spark,sachintyagi22/spark,hvanhovell/spark,lxsmnv/spark,jkbradley/spark,icexelloss/spark,byakuinss/spark,rednaxelafx/apache-spark,highfei2011/spark,ConeyLiu/spark,apache/spark,wangyum/spark,wzhfy/spark,bravo-zhang/spark,nchammas/spark,Panos-Bletsos/spark-cost-model-optimizer,spark-test/spark,xflin/spark,nchammas/spark,patrick-nicholson/spark,stanzhai/spark,sachintyagi22/spark,eyalfa/spark,big-pegasus/spark,darionyaphet/spark,actuaryzhang/spark,markhamstra/spark,gioenn/xSpark,WeichenXu123/spark,chuckchen/spark,apache/spark,panfengfeng/spark,liyichao/spark,lxsmnv/spark,HyukjinKwon/spark,HyukjinKwon/spark,ron8hu/spark,pgandhi999/spark,chuckchen/spark,kissmetrics/spark,akopich/spark,hvanhovell/spark,wangyum/spark,maropu/spark,ConeyLiu/spark,SHASHANKB/spark,HyukjinKwon/spark,facaiy/spark,taroplus/spark,xflin/spark,MLnick/spark,ueshin/apache-spark,nilsgrabbert/spark,ibm-research-ireland/sparkoscope,andrewor14/spark,tengpeng/spark,mzl9039/spark,ericvandenbergfb/spark,witgo/spark,ddna1021/spark,jianran/spark,nlalevee/spark,witgo/spark,lxsmnv/spark,ueshin/apache-spark,rednaxelafx/apache-spark,icexelloss/spark,narahari92/spark,narahari92/spark,zero323/spark,WindCanDie/spark,poffuomo/spark,hhbyyh/spark,maropu/spark,ptkool/spark,esi-mineset/spark,sureshthalamati/spark,bOOm-X/spark,LantaoJin/spark,HyukjinKwon/spark,cloud-fan/spark,jlopezmalla/spark,janewangfb/spark,ibm-research-ireland/sparkoscope,srowen/spark,cloud-fan/spark,rekhajoshm/spark,loneknightpy/spark,bravo-zhang/spark,apache-spark-on-k8s/spark,aray/spark,shaneknapp/spark,zero323/spark,nlalevee/spark,spark-test/spark,highfei2011/spark,narahari92/spark,bOOm-X/spark,bravo-zhang/spark,joseph-torres/spark,ddna1021/spark,saltstar/spark,dongjoon-hyun/spark,highfei2011/spark,ConeyLiu/spark,sahilTakiar/spark,cloud-fan/spark,panfengfeng/spark,aosagie/spark,esi-mineset/spark,actuaryzhang/spark,UndeadBaneGitHub/spark,alunarbeach/spark,shubhamchopra/spark,mdespriee/spark,andrewor14/spark,jianran/spark,sachintyagi22/spark,rezasafi/spark,someorz/spark,jrshust/spark,shaneknapp/spark,ptkool/spark,zhouyejoe/spark,vinodkc/spark,shubhamchopra/spark,highfei2011/spark,Panos-Bletsos/spark-cost-model-optimizer,nlalevee/spark,setjet/spark,someorz/spark,lvdongr/spark,cloud-fan/spark,spark-test/spark,aokolnychyi/spark,wangmiao1981/spark,zuotingbing/spark,shaneknapp/spark,pgandhi999/spark,actuaryzhang/spark,ron8hu/spark,wangmiao1981/spark,kiszk/spark,spark-test/spark,ibm-research-ireland/sparkoscope,wangmiao1981/spark,apache-spark-on-k8s/spark