HI,
You should take out the as.integer()
res<- unsplit(lapply(split(u3s,u3s$ID),function(x) { x$AUC24<-
if(all(is.na(x$AUC24))) NA else round(x$AUC24[!is.na(x$AUC24)]/2*
(2^(0:floor(log(4,2,3);x$WT<- if(all(is.na(x$WT))) NA else
x$WT[!is.na(x$WT)];x}),u3s$ID)
res$AUC24
#[1] NA NA
HI,
In the example you showed, there were only two cases: 1) For each ID, 2nd
element of AUC24 is NA. 2) or all the entries for a particular ID is missing.
Suppose you have NAs in 1st or 3rd element or multiple NAs (1 and 2, 2 and 3, 1
and 3 etc) in addition to the cases you already described.
HI Ahmed,
No problem.
You got the error because one of the IDs had all NAs for AUC24.
Also, In your dataset, there are NAs in BLADDERWALL, BLADDERWALLC, AUC12d,
Cmaxd, in addition to WT, and AUC24. Do you want to follow any particular
methodology for filling the NAs in these columns? or t
HI Ahmed,
No problem.
You got the error because one of the IDs had all NAs for AUC24.
Also, In your dataset, there are NAs in BLADDERWALL, BLADDERWALLC, AUC12d,
Cmaxd, in addition to WT, and AUC24. How do you want to fill those NAs?
res<-unsplit(lapply(split(u3s,u3s$ID),function(x) { x$AUC
Hi,
Please ?dput() your example dataset. Not sure this helps or not.
u3s<- read.table(text="Current-ID visit AUC Wight ID1
101 3 . . 1
101 4 10 13 2
101 5 . . 3
102 3 . . 4
102 4 4 10 5
102 5 . . 6
103 3 . . 7
103 4 6 9 8
103 5 . . 9",sep="",header=TRUE,na.strings=".",check.names=FALSE)
u3d<-
I'm sure I'm missing something really obvious in the "for loop"...
Here is simplified data for 3 patients, we need filling in Na's with same WT
for each patient, AUC halved for visit 3, doubled for visit 5 for the same
patient, based on visit 4
for(i in unique(u3s$ID)){
6 matches
Mail list logo