recover
位於 utils
包(package)。 說明
此函數允許用戶直接瀏覽任何當前活動的函數調用,並且適合作為錯誤選項。表達式 options(error = recover)
將使該選項成為錯誤選項。
用法
recover()
細節
當被召喚時,recover
打印當前調用列表,並提示用戶選擇其中之一。標準R
browser
然後從相應的環境中調用;用戶可以輸入普通的R要在該環境中評估的語言表達式。
在此調用中完成瀏覽後,鍵入 c
以從瀏覽器返回到 recover
。輸入另一個幀號以瀏覽更多內容,或輸入 0
退出 recover
。
使用 recover
在很大程度上取代了 dump.frames
作為錯誤選項,除非您確實想等待查看錯誤。如果在非交互模式下調用recover
,則其行為類似於dump.frames
。對於涉及大量數據的計算,recover
的優點是不需要複製所有環境即可在其中瀏覽。如果您決定退出交互式調試,請在任何框架中瀏覽時直接調用dump.frames
(請參閱示例)。
值
沒有返回任何有用的東西。但是,您可以直接從函數調用recover
,而不是通過示例中顯示的錯誤選項。在這種情況下,在您鍵入 0
退出 recover
後,執行將繼續。
兼容性說明
R recover
函數的使用方法與同名的S函數相同;因此,顯示的錯誤選項是指定錯誤操作的兼容方式。然而,實際函數本質上是不相關的,並且與用戶的交互方式完全不同。導航命令up
和down
不存在於R版本;相反,退出瀏覽器並選擇另一個框架。
例子
## Not run:
options(error = recover) # setting the error option
### Example of interaction
> myFit <- lm(y ~ x, data = xy, weights = w)
Error in lm.wfit(x, y, w, offset = offset, ...) :
missing or negative weights not allowed
Enter a frame number, or 0 to exit
1:lm(y ~ x, data = xy, weights = w)
2:lm.wfit(x, y, w, offset = offset, ...)
Selection: 2
Called from: eval(expr, envir, enclos)
Browse[1]> objects() # all the objects in this frame
[1] "method" "n" "ny" "offset" "tol" "w"
[7] "x" "y"
Browse[1]> w
[1] -0.5013844 1.3112515 0.2939348 -0.8983705 -0.1538642
[6] -0.9772989 0.7888790 -0.1919154 -0.3026882
Browse[1]> dump.frames() # save for offline debugging
Browse[1]> c # exit the browser
Enter a frame number, or 0 to exit
1:lm(y ~ x, data = xy, weights = w)
2:lm.wfit(x, y, w, offset = offset, ...)
Selection: 0 # exit recover
>
## End(Not run)
參考
John M. Chambers (1998).
Programming with Data; Springer.
See the compatibility note above, however.
也可以看看
browser
有關交互式計算的詳細信息; options
用於設置錯誤選項; dump.frames
保存當前環境以供以後調試。
相關用法
- R readRegistry 讀取 Windows 注冊表配置單元
- R removeSource 從函數或語言對象中刪除存儲的源
- R read.DIF 從電子表格輸入數據
- R remove.packages 刪除已安裝的軟件包
- R relist 允許重新列出未列出()的對象
- R read.socket 從套接字讀取或寫入
- R read.table 數據輸入
- R read.fortran 以類似 Fortran 的方式讀取固定格式數據
- R read.fwf 讀取固定寬度格式文件
- R roman 羅馬數字
- R rtags 類似 Etags 的 R 標記實用程序
- R rcompgen R 的補全生成器
- R select.list 從列表中選擇項目
- R COMPILE 編譯用於 R 的文件
- R browseVignettes 在 HTML 瀏覽器中列出暈影
- R hasName 檢查姓名
- R nsl 按主機名查找 IP 地址
- R edit 調用文本編輯器
- R create.post 準備電子郵件和帖子的輔助函數
- R hsearch-utils 幫助搜索實用程序
- R download.packages 從類似 CRAN 的存儲庫下載軟件包
- R DLL.version MS Windows 上的 DLL 版本信息
- R ls.str 列表對象及其結構
- R Rscript R 前端腳本
- R bug.report 發送錯誤報告
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Browsing after an Error。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。