내가 나에게 아래의 경고 메시지를 제공하는 대형 데이터 세트 (× 20 3667856)를 가지고na.locf()를 data.table과 함께 사용하면 ".internal.selfref detected invalid"경고 메시지의 가능한 원인은 무엇입니까?
: 나는 다음과 같은 간단한 (아직 유사) 예를 만들어 더 나은 상황을 이해하기 위해library(data.table)
library(zoo)
data[, new_quant_PD := na.locf(QUANT_PD,na.rm=FALSE), by=c('OBLIGOR_ID','PORTFOLIO','OBLIGATION_NUMBER')]
Warning messages:
1: In `[.data.table`(data, , `:=`(new_quant_PD, na.locf(QUANT_PD, ... :
Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by reference. At an earlier point, this data.table has been copied by R (or been created manually using structure() or similar). Avoid key<-, names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. Also, in R<=v3.0.2, list(DT1,DT2) copied the entire DT1 and DT2 (R's list() used to copy named objects); please upgrade to R>v3.0.2 if that is biting. If this message doesn't help, please report to datatable-help so the root cause can be fixed.
tmp = data.table(name=c('Zhao','Zhao','Zhao','Qian','Qian','Sun','Sun','Li','Li','Li'),score=c('B+',NA,'B',NA,NA,NA,'A',NA,'A-',NA))
tmp
name score
1: Zhao B+
2: Zhao NA
3: Zhao B
4: Qian NA
5: Qian NA
6: Sun NA
7: Sun A
8: Li NA
9: Li A-
10: Li NA
tmp[,new_score:=na.locf(score,na.rm=FALSE),by='name']
tmp
name score new_score
1: Zhao B+ B+
2: Zhao NA B+
3: Zhao B B
4: Qian NA NA
5: Qian NA NA
6: Sun NA NA
7: Sun A A
8: Li NA NA
9: Li A- A-
10: Li NA A-
이 작은 예는 경고 메시지를 전혀 생성하지 않습니다. 이론적으로
내가 할 수 OBLIGOR_ID
, PORTFOLIO
및 OBLIGATION_NUMBER
하고, 문제를 일으키는 어느 (들)입니다 (이다) 알아,하지만 data
의 모든 조합을 통해 루프는 내가 가지고 81293658 행 데이터 세트의 일부입니다. R에서 너무 많은 루프 시간을 가질 여유가 없다고 생각합니다.
모든 의견을 크게 환영합니다!
어떻게'data' 데이터 테이블을 만들었습니까? 경고는 뭔가 잘못되었을 수도 있음을 분명히 암시합니다. – Jaap