[R] debug only top level function
PIKAL Petr
petr@p|k@| @end|ng |rom prechez@@cz
Thu Jun 6 12:00:43 CEST 2019
Thanks Duncan.
I think you found it. I have an object called s within my function. I wanted to check it, so I hit "s". This did not bring the object but instead it change behaviour of debug function. I did not find this in help pages nor in R exts or R intro manual. Maybe it would be worth considering to add something about it to debug help page.
Best regards
Petr
> -----Original Message-----
> From: Duncan Murdoch <murdoch.duncan using gmail.com>
> Sent: Thursday, June 6, 2019 11:11 AM
> To: PIKAL Petr <petr.pikal using precheza.cz>; r-help using r-project.org
> Subject: Re: [R] debug only top level function
>
> On 06/06/2019 4:55 a.m., PIKAL Petr wrote:
> > Dear all
> >
> > I have a question about debug function. I did not use it for long time but my
> vague memory tell me, that when I used debug(myfunction) in past, only
> myfunction was debugged and browser ignored any embedded function.
> >
> > example (simple)
> >
> > fff <- function(x) mean(x, na.rm=T)
> >
> > when I issue
> >> debug(fff)
> >> fff(1:10)
> > debugging in: fff(1:10)
> > debug at #1: mean(x, na.rm = T)
> > Browse[2]>
> > debugging in: mean(x, na.rm = T)
> > debug: UseMethod("mean")
> > Browse[3]>
> > debugging in: mean.default(x, na.rm = T) ...
> > it starts debugging mean function. I understand that it is indicated by
> Browse[n] but it could be quite messy if I have many embedded functions and
> difficult to follow.
> >
> > Can I persuade debug function not to bother with embedded functions (e.g.
> mean, median, mad, ...) and debug only my top level code?
>
> There are several commands available. Type "help" to see them:
>
> n next
> s step into
> f finish
> c or cont continue
> Q quit
> where show stack
> help show help
> <expr> evaluate expression
>
>
> You want "n", and are getting "s". I believe if you hit Enter without choosing
> one, it will do the same as the previous time, so you've probably used "s"
> sometime in the past.
>
> Duncan Murdoch
>
> >
> > Best regards
> > Petr
> >
> >> sessionInfo()
> > R Under development (unstable) (2018-03-07 r74369)
> > Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10
> > x64 (build 17763)
> >
> > Matrix products: default
> >
> > locale:
> > [1] LC_COLLATE=Czech_Czechia.1250 LC_CTYPE=Czech_Czechia.1250 [3]
> > LC_MONETARY=Czech_Czechia.1250 LC_NUMERIC=C [5]
> > LC_TIME=Czech_Czechia.1250
> >
> > attached base packages:
> > [1] stats datasets utils grDevices graphics methods base
> >
> > other attached packages:
> > [1] MASS_7.3-49 readxl_1.0.0 lattice_0.20-35 fun_0.1
> >
> > loaded via a namespace (and not attached):
> > [1] Rcpp_0.12.16 cellranger_1.1.0 grid_3.5.0 plyr_1.8.4
> > [5] gtable_0.2.0 scales_0.5.0 ggplot2_2.2.1 pillar_1.2.1
> > [9] rlang_0.2.0 lazyeval_0.2.1 rpart_4.1-13 tools_3.5.0
> > [13] munsell_0.4.3 compiler_3.5.0 colorspace_1.3-2 tibble_1.4.2
> >>
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
More information about the R-help
mailing list