1

偶然、ls() を使用して見つけた ls という変数を作成しました。したがって、同じ名前の関数 ls() と変数が存在します。変数へのアクセスにすべての試行が失敗したため、変数の種類と内容がわかりません。

ls 

ls() 関数の本体を返しました。

get("ls")

get(ls) で返されたエラー: 無効な最初の引数

get("ls", mode="numeric")

モード「数値」のオブジェクト「ls」が見つかりませんでした

get("ls", mode=!"function")

は有効な引数ではありません。では、どうすれば変数にアクセスできますか? class(ls) と str(ls) も試しましたが、すべて関数として ls を参照しています。

これに対する適切な質問が見つかりません。しかし、私はそれについて以前に読んだことがあると確信しています。なので重複投稿でしたらすみません。ヘルプとリンクをいただければ幸いです。

編集:の出力dput(ls()[grep("^ls$", ls())])は次 のとおりです。

"ls"

編集:の出力dput(ls())は次のとおりです。

c("bplo.anno", "c", "combinations.formula", "combo.form", "df", "df.group.unique", "df.test", "dir.work", "form.compl", "fun.boot.lm.stepAIC.4", "fun.boot.lm.stepAIC.5", "fun.CoerceListOfVectorToMatrix", "fun.data.preparation", "fun.dcor.DataFrame", "fun.expand.complete.interaction", "fun.g.ellipse.orig", "fun.K_fold", "fun.lappend", "fun.lm.subset", "fun.lm_AIC", "fun.lst.powerset", "fun.MaxToMinModel.adjrsq", "fun.MaxToMinModel.rsq", "fun.plot.circle", "fun.results", "fun.rs.dcor", "fun.vectorcoerce", "group", "height", "i", "j", "k", "ls", "ls.boot", "ls1", "lst.boot.result", "oldwd", "regressor.names", "response.name", "result.df", "rs.dcor", "source.filename", "tbl.bt", "tbl.nm")
4

1 に答える 1

3

1 つの可能性は、関数をコピーしたことですls()

ls = ls

これはあなたの「問題」を再現します

get("ls")

関数を返します。同じエラー メッセージが表示されます。

R> get("ls", mode="numeric")
Error in get("ls", mode = "numeric") : 
  object 'ls' of mode 'numeric' was not found
R> get("ls", mode=!"function")
Error in !"function" : invalid argument type

dput同じ結果が得られます。

R> dput(ls()[grep("^ls$", ls())]) 
"ls"
于 2012-04-19T08:40:08.087 に答える