[datatable-help] Avoid warnings when obtaining fictitious rows

Frank S. f_j_rod at hotmail.com
Tue Sep 8 13:10:46 CEST 2015


Hi Arun and sorry for my insistence. If I'm right, wraping the entire expression we can identify that there is one missign data in $visit for  id=2:
 
> DT[, print(list(start, visit=as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31"))),end)), by=id]

[[1]]  # Data for subject id=2[1] "2007-01-01" "2007-01-01" "2007-01-01"
$visit[1] "2007-12-31" "2008-12-31” ##########  <~~~ here’s the issue that results in warning. [[3]][1] "2009-05-01" "2009-05-01" "2009-05-01"
But precisely, the output I desired for id=2 consists on keeping rows of only those "complete" observations for columns start, visit and end,.I only want to keep by rows the first and second columns, because the following 31 December would be  2009-12-31, which is older than the corresponding end=2009-05-01. That is:    id             start              visit             end
1:  2 2007-01-01  2007-12-31 2009-05-01
2:  2 2007-01-01  2008-12-31 2009-05-01
Trying to follow your suggestions, I've written: > DT[unique(DT), 
    {N = as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31")))
    .(start, visit = visit[N], end)
    }, by=id] But it returns me an error message. Can you help me to find a way out of this mess?  





 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20150908/3bdb58d5/attachment.html>


More information about the datatable-help mailing list