0

I'd like to be able to create a function that returns 3 lists. For instance:

Objects <- function(SetType, 2Type){
  1Set <- list()
  1Set$type <- SetType
  2Set <- list()
  2Set$type <- 2Type
  3Set <- list()

  return(1Set)
  return(2Set)
  return(3Set)
}

This only returns 1Set.

One option that I can think of is to create 2 functions that simply create 2Set and 3Set and then call upon them in the Objects function, but is there a better way of achieving this?

1 Answers1

1

Also check this link

Objects <- function(SetType, 2Type){
  1Set <- list()
  1Set$type <- SetType
  2Set <- list()
  2Set$type <- 2Type
  3Set <- list()

  return(list(1Set,2Set,3Set))
}
Ret=Objects(SetType, 2Type)
1Set=Ret[[1]]
2Set=Ret[[2]]
3Set=Ret[[3]]
BENY
  • 317,841
  • 20
  • 164
  • 234