0
이 매우 기본적인 괜찮
,하지만 난 R.에서 '중첩'(2 단계) 목록을 만들기 위해 노력하고 다단계 목록을 만들R -
나는 네 개의 파일이 맘에 참조한 :
한편files=c('path-to-file1',
'path-to-file2',
'path-to-file3',
'path-to-file4')
, 나는 각 파일에 대해 수행하는 데 필요한 네 가지 작업이 있습니다
ops=c('operation1,
operation2,
operation3,
operation4')
내가 루프 (파일을 통해 하나 및 운영을 통해 하나) "를"두를하고있는 중이 야하고, 그러므로 나는 필요로하는 2 단계 목록을 채워야한다.
- the 1st element of the first level is "file1";
- the 1st element of the second level is "operation1"
- the 2nd element of the second level is "operation2"
- the 3nd element of the second level is "operation3"
- the 4nd element of the second level is "operation4"
- the 2nd element of the first level is "file2";
- the 1st element of the second level is "operation1"
- the 2nd element of the second level is "operation2"
- the 3nd element of the second level is "operation3"
- the 4nd element of the second level is "operation4"
- and so on...
이렇게 다중 레벨 목록을 만드는 가장 좋은 방법은 무엇입니까?
편집 : 이것은 내가 찾던의 종류 : 몇 가지 테스트 후
files=c('path-to-file1',
'path-to-file2',
'path-to-file3',
'path-to-file4')
ops=c('operation1,
operation2,
operation3,
operation4')
# Create empty list to hold "operations" objects
list.ops = vector('list', length(ops))
# Create multi-level list lo hold both "files" and "operations" objects
multi.list = ? (how to create it? see loops below)
for (i in 1:length(files)){
for (j in 1:length(ops)){
(do some stuff)
list.ops[[j]] = result of some operations
}
multi.list[[i]][[j]] = list.ops[[j]]
}
작동이란 무엇입니까? 그것은 기능입니까? 귀하의 예를 기반으로, 그것은 단일 문자열입니다. 다른 사람들이 당신의 문제에 대해 작게 재현 할 수있는 예제를 보여주십시오. – akrun
@akrun 작업은 실제로 많은 수학 계산입니다. 우리가 크기가 큰 위성 이미지에 대해 이야기하고 있기 때문에 의미있는 데이터 세트로 재현하기가 매우 어렵습니다. – thiagoveloso
@akrun, 저는 제 스크립트에있는 것과 비슷한 루프를 추가하여 질문을 편집했습니다. 잘하면 이해하기가 더 쉬울 것입니다 ... – thiagoveloso