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