1

I want to return several data.table type objects from a function.

return(list(data.table(train), data.table(test))) and train = tt_list[1] dont' return type of data.table but type of list.

I tried to convert but either got an error (train = as.data.table(tt_list[1]) cause:

Error in FUN(X[[i]], ...) : )

or the process took plenty of time and the result hasn't been there..

My question is: should I give up my function in this case an do the job just in the flow or is there some better container to keep data.table inside than list? Everything it's ok without the function.

Jaap
  • 81,064
  • 34
  • 182
  • 193
Peter.k
  • 1,475
  • 23
  • 40

1 Answers1

5
return(list(train = data.table(train), test =data.table(test)))
train=tt_list$train

here:Returning multiple objects in an R function and here: How to assign from a function which returns more than one value?

Community
  • 1
  • 1
timat
  • 1,480
  • 13
  • 17