偶然我創建了一個名爲ls的變量,我用ls()發現了它。所以存在一個函數ls()和一個名字相同的變量。我不知道它是什麼類型的變量,也不知道內容,因爲所有的嘗試都無法訪問變量。同名變量和函數(ls)在R
ls
返回了ls()函數的主體。
get("ls")
返回的GET(LS)錯誤:模式
get("ls", mode="numeric")
對象 'LS' 無效的第一個參數 '數字' 未找到
get("ls", mode=!"function")
是不是一個有效的參數。 那麼如何訪問變量?我也嘗試過類(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")
什麼'STR(LS)'給你? – csgillespie 2012-04-19 08:20:02
str(ls)返回函數(name,pos = -1,envir = as.environment(pos),all.names = FALSE, pattern) – Sebastian 2012-04-19 08:32:10
我不能複製這個,你確定變量'ls'是否存在?你可以試試'.GlobalEnv $ ls',但我認爲如果它存在於你的全局環境中,你應該只需要用'ls'來訪問它。 – 2012-04-19 08:38:40