0
を作成し、私はこれを好きに参照する4つのファイルがありますR - [OK]を、これは非常に基本的なものですが、私はR.</p> <p>に「ネストされた」(2レベル)のリストを作成しようとしていますマルチレベルリスト
をfiles=c('path-to-file1',
'path-to-file2',
'path-to-file3',
'path-to-file4')
一方、私は、各ファイルに対して実行する必要がある四つの異なる操作があります。
ops=c('operation1,
operation2,
operation3,
operation4')
を私はループ(ファイルの上で1つおよび運用上の1つ)「の」2をやっている、としたがって、私は、必要とする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...
このように複数のレベルのリストを作成するにはどうすればよいですか?これは私が探しています何の一種である:
EDITいくつかのテストの後
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