I'm working with a list of lists - let's call it L
- in R, where the sub-lists are all the same length & padded with NAs. Ideally, I'd like to remove just the NA elements from each sublist, and one solution I've come up with is L <- lapply(L, na.omit)
. It seems to almost work; however, for each sub-list, the behavior is such that, for example,
[[1]]
[1] "0" "12345" "12346" "12347" "12348" "12349" "12340" "12341" "12342" NA NA NA NA NA NA
[16] NA NA NA NA NA NA NA NA NA NA NA
〜になる
[[1]]
[1] "0" "12345" "12346" "12347" "12348" "12349" "12340" "12341" "12342"
attr(,"na.action")
[1] 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
attr(,"class")
[1] "omit"
私はちょっと思っています。正直なところ、私のリストには余分な attr()
などがありますか?それらをリストに追加しないソリューションはありますか?私は na.exclude
を試しましたが、同じ結果が得られます。私は行方不明のものがありますか?前もって感謝します : )