<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I’m not sure what you’re doing. I meant to wrap the entire expression with `print()`:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><div id="bloop_customfont" style="margin: 0px;">DT[, print(list(start, visit=as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31"))),end)), by=id]</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">[[1]]</div><div id="bloop_customfont" style="margin: 0px;">[1] "2007-01-01" "2007-01-01" "2007-01-01"</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">$visit</div><div id="bloop_customfont" style="margin: 0px;">[1] "2007-12-31" "2008-12-31” # <~~~ here’s your issue that results in warning.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">[[3]]</div><div id="bloop_customfont" style="margin: 0px;">[1] "2009-05-01" "2009-05-01" "2009-05-01"</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">————</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">[[1]]</div><div id="bloop_customfont" style="margin: 0px;">[1] "2010-09-30" "2010-09-30"</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">$visit</div><div id="bloop_customfont" style="margin: 0px;">[1] "2010-12-31" "2011-12-31"</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">[[3]]</div><div id="bloop_customfont" style="margin: 0px;">[1] "2012-03-25" "2012-03-25"</div><div id="bloop_customfont" style="margin: 0px;"><br></div></div> <br> <div id="bloop_sign_1441055071526594048" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Arun</div></div> <br><p class="airmail_on" style="color:#000;">On 28 Aug 2015 at 17:16:59, Frank S. (<a href="mailto:f_j_rod@hotmail.com">f_j_rod@hotmail.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div class="hmmessage"><div></div><div>







<title></title>


<div dir="ltr">Hi Arun,<br>
 <br>
First of all, thnak you for answering once again!<br>
 <br>
Following your suggestion, I've tried to wrap my
j-expression:<br>
 <br>
> unique(DT[ , print(visit <-
as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31")))),by=id])<br>

# [1] "2007-12-31" "2008-12-31"<br>
# [1] "2010-12-31" "2011-12-31"<br>
# Empty data.table (0 rows) of 1 col: id<br>
 <br>
But i do not have any idea which the problem is.<br>
 <br>
Please, can you give me any  additional help?<br>
 <br>
<div>
<hr id="stopSpelling">
Subject: Re: [datatable-help] Avoid warnings when obtaining
fictitious rows<br>
From: aragorn168b@gmail.com<br>
Date: Fri, 28 Aug 2015 11:55:27 +0200<br>
CC: datatable-help@lists.r-forge.r-project.org<br>
To: f_j_rod@hotmail.com<br>
<br>
<div>Wrap the j-exp with print. It will help you identify what the
issue is.<br>
<br>
Arun</div>
<div><br>
On 27 Aug 2015, at 13:58, Frank S. <<a href="mailto:f_j_rod@hotmail.com">f_j_rod@hotmail.com</a>>
wrote:<br>
<br></div>
<blockquote>
<div>
<div dir="ltr">Hello everyone,<br>
 <br>
I can execute my R code but I obtain a warning message and I do not
know how to avoid it.<br>
Let's consider, just by way of example, the following data table
with 2 subjects under study:<br>
 <br>
DT <- data.table(id=c(2,2,2,11,11),<br>
 
start=c(rep(as.Date("2007-01-01"),3),rep(as.Date("2010-09-30"),2)),<br>

 
visit=c("2007-03-01","2008-07-15","2008-11-17","2010-10-15","2011-05-17"),<br>

 
end=c(rep(as.Date("2009-05-01"),3),rep(as.Date("2012-03-25"),2)))<br>

 <br>
I get a new data table which assigns a fictitious visit on each 31
December between<br>
the dates "start" and "end" corresponding to each individual:<br>
 <br>
DT.new <- unique(DT[,list(start,<br>
 visit=as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31"))),<br>

 end), by=id])<br>
 <br>
Warning messages:<br>
In `[.data.table`(DT, , list(start, visit =
as.Date(c(paste0(year(start[1]):(year(end[1]) -  :<br>
  Column 2 of result for group 1 is length 2 but the longest
column in this result is 3. Recycled leaving remainder of 1 items.
This warning is once only for the first group with this
issue.<br>
 <br>
The R code works, but how can I avoid the warning?<br>
 <br>
Many thanks for any suggestion!!<br></div>
</div>
</blockquote>
<blockquote>
<div>
<span>_______________________________________________</span><br>
<span>datatable-help mailing list</span><br>
<span><a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a></span><br>

<span><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></span></div>
</blockquote>
</div>
</div>


</div></div></span></blockquote></body></html>