Created
May 19, 2016 12:16
-
-
Save IsmailM/ed17e8b2e6686db3218cb49436ea577d to your computer and use it in GitHub Desktop.
shows how to use named lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!