0

Is it possible to return two data frames in a function like this:

test <- function(){
  my.df <- data.frame(
    col1 = sample(c(1,2), 10, replace = TRUE),
    col2 = as.factor(sample(10)))
  other.df <- data.frame(
    col3 = letters[1:10],
    col4 = sample(c(TRUE, FALSE), 10, replace = TRUE))
  return(my.df, other.df)
}
a,b=test()

1 Answers1

1

Return them in a list

return(list(my.df,other.df))
stefan_aus_hannover
  • 1,777
  • 12
  • 13