expand.grid를 복수로 생성할 때
R/handling2019. 5. 25. 01:46
expand.grid(rep(list,n)) : 각각의 list에 대해 모든 조합을 생성
예제
com=function(kb_station,cn){
data=as.matrix(expand.grid(rep(list(kb_station),cn)))
for(i in 1:(ncol(data)-1)){
data=data[data[,i]>data[,i+1],]}
return(data)}
cn=2
kb_station=1:11
temp=com(kb_station,cn)
temp=cbind(temp,NA)
com=function(kb_station,cn){
n=0;ls=list()
while(T){
n=n+1
ls[[cn-n+1]]=kb_station
kb_station=kb_station[-1]
if(n==cn)break
}
data=as.matrix(expand.grid(ls))
for(i in 1:(ncol(data)-1)){
data=data[data[,i]>data[,i+1],]}
return(data)}
scaling
R/handling2019. 4. 16. 05:37
'R > handling' 카테고리의 다른 글
expand.grid를 복수로 생성할 때 (0) | 2019.05.25 |
---|---|
reshape (0) | 2019.04.14 |
plyr 패키지를 통한 핸들링 (0) | 2019.04.12 |
파일 불러오기 (0) | 2019.04.08 |
reshape
R/handling2019. 4. 14. 05:28
'R > handling' 카테고리의 다른 글
expand.grid를 복수로 생성할 때 (0) | 2019.05.25 |
---|---|
scaling (0) | 2019.04.16 |
plyr 패키지를 통한 핸들링 (0) | 2019.04.12 |
파일 불러오기 (0) | 2019.04.08 |
plyr 패키지를 통한 핸들링
R/handling2019. 4. 12. 05:19
파일 불러오기
R/handling2019. 4. 8. 03:34
'R > handling' 카테고리의 다른 글
expand.grid를 복수로 생성할 때 (0) | 2019.05.25 |
---|---|
scaling (0) | 2019.04.16 |
reshape (0) | 2019.04.14 |
plyr 패키지를 통한 핸들링 (0) | 2019.04.12 |