[datatable-help] Avoid warnings when obtaining fictitious rows

Frank S. f_j_rod at hotmail.com
Fri Aug 28 17:16:52 CEST 2015


Hi Arun,
 
First of all, thnak you for answering once again!
 
Following your suggestion, I've tried to wrap my j-expression:
 
> unique(DT[ , print(visit <- as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31")))),by=id])
# [1] "2007-12-31" "2008-12-31"
# [1] "2010-12-31" "2011-12-31"
# Empty data.table (0 rows) of 1 col: id
 
But i do not have any idea which the problem is.
 
Please, can you give me any  additional help?
 
Subject: Re: [datatable-help] Avoid warnings when obtaining fictitious rows
From: aragorn168b at gmail.com
Date: Fri, 28 Aug 2015 11:55:27 +0200
CC: datatable-help at lists.r-forge.r-project.org
To: f_j_rod at hotmail.com

Wrap the j-exp with print. It will help you identify what the issue is.

Arun
On 27 Aug 2015, at 13:58, Frank S. <f_j_rod at hotmail.com> wrote:




Hello everyone,
 
I can execute my R code but I obtain a warning message and I do not know how to avoid it.
Let's consider, just by way of example, the following data table with 2 subjects under study:
 
DT <- data.table(id=c(2,2,2,11,11),
  start=c(rep(as.Date("2007-01-01"),3),rep(as.Date("2010-09-30"),2)),
  visit=c("2007-03-01","2008-07-15","2008-11-17","2010-10-15","2011-05-17"),
  end=c(rep(as.Date("2009-05-01"),3),rep(as.Date("2012-03-25"),2)))
 
I get a new data table which assigns a fictitious visit on each 31 December between
the dates "start" and "end" corresponding to each individual:
 
DT.new <- unique(DT[,list(start,
 visit=as.Date(c(paste0(year(start[1]):(year(end[1])-1),"-12-31"))), 
 end), by=id])
 
Warning messages:
In `[.data.table`(DT, , list(start, visit = as.Date(c(paste0(year(start[1]):(year(end[1]) -  :
  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.
 
The R code works, but how can I avoid the warning?
 
Many thanks for any suggestion!!
 		 	   		  
_______________________________________________
datatable-help mailing list
datatable-help at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20150828/49f93c0d/attachment.html>


More information about the datatable-help mailing list