Skip to content

Instantly share code, notes, and snippets.

@IsmailM
Created May 19, 2016 12:16
Show Gist options
  • Save IsmailM/ed17e8b2e6686db3218cb49436ea577d to your computer and use it in GitHub Desktop.
Save IsmailM/ed17e8b2e6686db3218cb49436ea577d to your computer and use it in GitHub Desktop.
shows how to use named lists
# A really really cool method that does extremely important stuff (Careful, don't break it or the world might fall apart)
# x has to be larger than 2)
random <- function(x) {
n <- sample(1:x, 3) # get 3 random numbers between 1 and x
results <- list(num1 = n[1],
num2 = n[2],
num3 = n[3])
return(results)
}
out <- random(20)
out$num1
out$num2
out$num3
@Nazrath10R
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment