I am trying to pass arguments to a function which are factor data types, while defining default value as NULL. A simplified example is below:

```
my_function <-  function(my_arg = c(NULL,"this","that")){
    Do stuff here...
}

```

This does not seem to work, as if I define the function as follows:

```
my_function <-  function(my_arg = c(NULL,"this","that")){
    print(my_arg)
} 

```

the result is :

```
> my_function()

```

[1] "this" "that"

Not sure how to have a parameter passed as a factor which has a defined default value of NULL. Thanks!

EDIT:

Thank you for your responses, but these do not really answer my question. Perhaps I was not specific enough. My example is a highly simplified example of what I am actually trying to accomplish, but what I need is to specify an argument that can take on one of three values -- "this", "that", and NULL. Further to this, I need to set the default value to NULL. I can simply set my\_arg = NULL, but then I have not specified in the function signature that my arg must be one of these three options. Your solutions do neither of these for me. If I pass as a list, say

```
my_function <-  function(my_arg = list(NULL,"this","that")){
  print(my_arg)
}

```

This results in the following:

```
> my_function("this")
[1] "this"
> my_function("asdf")
[1] "asdf"
> my_function()
[[1]]
NULL

[[2]]
[1] "this"

[[3]]
[1] "that"

```

So if I do not pass a value to my\_args specifically, it will iterate through the function using each value listed in the signature. What I need is for the function to accept either NULL, "this", or "that" as values for the argument, while setting NULL as the default if nothing is passed.