Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active September 29, 2017 17:57
Show Gist options
  • Save ZeccaLehn/06d85adb49d3dbae2a457141ce691b5b to your computer and use it in GitHub Desktop.
Save ZeccaLehn/06d85adb49d3dbae2a457141ce691b5b to your computer and use it in GitHub Desktop.
Function Returning List of Multiple Objects in R
# Function
xylist <- function(start, finish){
  
  x <- seq(start, finish)
  y <- seq(start, finish)^2
  
  return(list("x" = x, "y" = y))
  
}

xyOut <- xylist(1,5)
xyOut$x
xyOut$y
# Outputs
xyOut <- xylist(1,5)

xyOut$x
[1] 1 2 3 4 5
xyOut$y
[1]  1  4  9 16 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment