Code Fix

上級 › match.arg に候補外の値を渡すと 'arg' should be one of エラーになる › パターン4

match.arg に候補外の値を渡すと 'arg' should be one of エラーになる

match.arg()で選択肢を制限した引数に、定義された候補のどれとも一致しない値を渡すと、'arg' should be one ofというエラーになります。

 1  choose_plan <- function(plan = c("free", "basic", "pro")) {
 2    plan <- match.arg(plan)
 3    cat("plan:", plan, "\n")
 4  }
 5  choose_plan(_________)
                    ^
'arg' should be one of “free”, “basic”, “pro”

空欄を埋めて実行を通す

広告
広告スロット(未設定)

match.arg に候補外の値を渡すと 'arg' should be one of エラーになる

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)