Skip to content

Instantly share code, notes, and snippets.

@sjp
Created March 22, 2010 11:09
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 sjp/339979 to your computer and use it in GitHub Desktop.
Save sjp/339979 to your computer and use it in GitHub Desktop.
> f <- function(x, y, z) { print(c(x, y, z)) }
> f(2, 3, 9)
[1] 2 3 9
> f(z = 9, x = 2, y = 3)
[1] 2 3 9
> f(z = 9, 3, x = 2)
[1] 2 3 9
> f <- function(x, y, z = 9) { print(c(x, y, z)) }
> f(x = 2, y = 3)
[1] 2 3 9
> f <- function(x = 2, y = 3, z = 9, all = c(x, y, z)) {
+ print(all)
+ }
> f(z = 5)
[1] 2 3 5
> f()
[1] 2 3 9
> f(z = 4, x = 6)
[1] 6 3 4
> f <- function(x, ...) { print(list(...)) }
> f(2, y = 3, 9)
$y
[1] 3
[[2]]
[1] 9
> f <- function(alongString, alsoAString, anotherString) {
+ print(c(alongString, alsoAString, anotherString))
+ }
> f(alo = 2, als = 3, an = 9)
[1] 2 3 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment