https://github.com/ColinFay/debugin
An RStudio Addin for Debugging
https://github.com/ColinFay/debugin
Last synced: 4 months ago
JSON representation
An RStudio Addin for Debugging
- Host: GitHub
- URL: https://github.com/ColinFay/debugin
- Owner: ColinFay
- License: other
- Archived: true
- Created: 2018-05-03T20:50:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-07T12:37:40.000Z (almost 7 years ago)
- Last Synced: 2024-08-13T07:14:05.636Z (8 months ago)
- Language: R
- Size: 6.57 MB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ColinFay/debugin - An RStudio Addin for Debugging (R)
README
---
output:
md_document:
variant: markdown_github
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```[](https://img.shields.io/badge/lifecycle-experimental-orange.svg)
# debugin
Developpers debug. A lot. One way to do it in R is to wrap your functions in `debug()`, and run it again. And then we have `debug()` it, and need to `undebug()` them. Or we can also call `debugonce()`.
## Debug functions
Developpers like to be efficient. Writing debug and undebug can break your workflow. So why not doing it with a keyboard shortcut?
That's what `{debugin}` does: you highlight a function in your RStudio windows, and the addin does the job of `debug()`, `undebug()`, or `debugonce()`.
> Note: using debugin is better with keyboard shortcuts
The addin allows :
+ `debug()`
+ `debugonce()`
+ `undebug()`## Debug with message
You can access the debug_with_messages utils functions:
```{r}
library(debugin)
a <- function() "plop"
debug_with_message(a)
undebug_with_message(a)
```Comparing to base function, these functions does nothing more than printing a message to the user. Hence the use of an addin.
## trace_back
With base R, the traceback is printed in reverse order (from the last call to the first). With `trace_back()`, you get the call stack in the order the calls were made. Plus, the first call is printed in blue, and the call causing the error in printed in red (if your R session support ANSI colors).
```{r eval=FALSE}
my_fun <- function(x){
dplyr::select(x, 1:10)
}
my_fun(1:100)
trace_back()
```
## Browse / Unbrowse
Unbrowse turns all the `browser()` to `#browser()`, Browse does the opposite.

Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.