Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私の質問は簡単です。
x=list(type="call") FUN <- function(x=list(type=c("call","put"))) { x$type=match.arg(x$type) }
これはエラーを返します:
> FUN(x) Error in match.arg(x$type) : 'arg' should be one of “”
何か案は?
おそらくこれはあなたが望むものです:
FUN <- function(x=list(type=c("call","put"))) { x$type=match.arg(x$type, c('call', 'put')) } > print(FUN()) [1] "call" > print(FUN(x)) [1] "call" > print(FUN(list(type="put"))) [1] "put"