Skip to content

Instantly share code, notes, and snippets.

@ajdamico
Created October 31, 2011 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajdamico/1329117 to your computer and use it in GitHub Desktop.
Save ajdamico/1329117 to your computer and use it in GitHub Desktop.
roger peng's listlabeling challenge
#roger peng's listlabeling challenge from
#http://simplystatistics.tumblr.com/post/11988685443/computing-on-the-language
#create three example variables for a list
x <- 1
y <- 2
z <- "hello"
#create the function
makeList <- function(...) {
#put all values into a list
argument_values <- list(...)
#save all argument names into another list
argument_names <- as.list(sys.call())
#cycle through the first list and label with the second, ignoring the function itself
for ( i in 2:length(argument_names) ){
names(argument_values)[i-1] <- argument_names[i]
}
#return the newly-labeled function
argument_values
}
#display the results
makeList( x , y , z )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment