R에서 목록을 사용하는 것은 까다로울 수 있습니다. NULL에 대한 목록 요소를 설정하면 목록에서 제거와 동일한 지R의 목록 요소를 참조하는 것이 모호합니다. 올바르게 수행하는 방법은 무엇입니까?
opts = list()
opts$value = NULL
opts$valueDefault = c(1,2,3)
print(opts) # note: displaying the whole list does not reveal
# the element "value"
$valueDefault
[1] 1 2 3
print(opts$value) # with this notation I do not get the correct (intended)
# result
[1] 1 2 3
print(opts[["value"]]) # with this notation I do
NULL
목록 요소를 NULL로 설정하는 것은 목록에서 제거하는 것과 같습니다. 그 시점의 목록에는 문자 그대로 valueDefault라는 단일 요소 만 들어 있습니다. 차이를 보려면 값을 대신 NA로 설정하십시오. – Dason
당신은'? "$"' – Dason
을 읽어야합니다. 매우 빠른 응답을 보내 주셔서 감사합니다. (이미 존재하지 않는) NULL 요소를 참조하는 것은 물론 NULL을 반환했습니다. done (opts $ another) – Egus