Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
各要素がベクトルであるリスト L を指定すると、各 i に対して、V[i] が L[[i]] の長さになるような整数ベクトル V を返す関数を書きたいと思います。
sapply を使用します。
sapply(L, length)
例えば:
L = list(c(1, 2, 3), c(2, 3), c(3, 4, 5, 6)) sapply(L, length) # [1] 3 2 4