Hi Marna,
This may be what you want:
get_latest<-function(x,format="%m/%d/%Y") {
x<-unlist(x)
x[nchar(x)==0]<-NA
if(all(is.na(x))) return(NA)
else return(format(max(as.Date(x,format),na.rm=TRUE),format))
}
daT$output1<-apply(daT[,2:4],1,get_latest)
The empty value in daT gave a bit of trouble
Hi R Users,
I have been struggling to extract the data based on conditional values in
different columns. I have a very big dataset (rows) and a couple of
columns. here an example of the dataset is:
daT<-structure(list(ID = c("id1", "id2", "id3", "id4", "id5", "id6",
"id7"), First_detectiondate =
2 matches
Mail list logo