<div dir="ltr">You can make a wrapper for something like<div><br></div><div>> DT <- data.table(date=Sys.Date()[0],id=character(0),value=numeric(0))</div><div><br></div><div># examine structure</div><div>> str(DT)</div><div><div>Classes ‘data.table’ and 'data.frame': 0 obs. of 3 variables:</div><div> $ date :Class 'Date' num(0) </div><div> $ id : chr </div><div> $ value: num </div><div> - attr(*, ".internal.selfref")=<externalptr> </div></div><div><br></div><div># try appending</div><div>> str(rbind(DT,list(Sys.Date(),"A",1)))<br></div><div><div>Classes ‘data.table’ and 'data.frame': 1 obs. of 3 variables:</div><div> $ date : Date, format: "2015-07-23"</div><div> $ id : chr "A"</div><div> $ value: num 1</div><div> - attr(*, ".internal.selfref")=<externalptr> </div></div><div><br></div><div>--Frank</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 23, 2015 at 5:51 AM, statquant3 <span dir="ltr"><<a href="mailto:statquant@outlook.com" target="_blank">statquant@outlook.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wanted to create a function that creates an empty data.table with specified<br>
column types.<br>
emptyDT <- function(colNames,colTypes){...}<br>
I would call<br>
emptyDT(c('date','id','value'),c('Date','Character','Numeric'))<br>
<br>
Is there something available for this already ?<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://r.789695.n4.nabble.com/create-empty-data-table-tp4710237.html" rel="noreferrer" target="_blank">http://r.789695.n4.nabble.com/create-empty-data-table-tp4710237.html</a><br>
Sent from the datatable-help mailing list archive at Nabble.com.<br>
_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
</blockquote></div><br></div>