Re: [R] debug only top level function
>>>>> Duncan Murdoch >>>>> on Thu, 6 Jun 2019 07:38:40 -0400 writes: > On 06/06/2019 6:00 a.m., PIKAL Petr wrote: >> 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. > It's in the ?browser help page, which is linked from ?debug. > Duncan Murdoch Indeed. As it is not the first time, users did not "find" this, I have made the links a bit more visible (for future R versions), now. I'd use '(s)' instead of 's' [and more often and importantly, I have a variable 'n' somewhere and need to use '(n)' very regularly. For smallish situations, btw, the use of ls.str() comes very handy. It has to be noted that unfortunately, the difference between 'n' and 's' and 'c' has been a bit "blurred" for byte compiled functions, and as the default JIT level is high, I had occasionallz wanted an easy way to revert the byte compilation before debugging or another way to get rid of this drawback.. Martin >> >> Best regards >> Petr >> >>> -Original Message- >>> From: Duncan Murdoch >>> Sent: Thursday, June 6, 2019 11:11 AM >>> To: PIKAL Petr ; r-help@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 >>> 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.0lattice_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.1pillar_1.2.1 >>>> [9] rlang_0.2.0 lazyeval_0.2.1 rpart_4.1-13 tools_3.5.0 >>>> [13] munsell_0.4.3compiler_3.5.0 colorspace_1.3-2 tibble_1.4.2 __ R-help@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.
Re: [R] debug only top level function
On 06/06/2019 6:00 a.m., PIKAL Petr wrote: 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. It's in the ?browser help page, which is linked from ?debug. Duncan Murdoch Best regards Petr -Original Message- From: Duncan Murdoch Sent: Thursday, June 6, 2019 11:11 AM To: PIKAL Petr ; r-help@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 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.0lattice_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.1pillar_1.2.1 [9] rlang_0.2.0 lazyeval_0.2.1 rpart_4.1-13 tools_3.5.0 [13] munsell_0.4.3compiler_3.5.0 colorspace_1.3-2 tibble_1.4.2 __ R-help@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/ __ R-help@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.
Re: [R] debug only top level function
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 > Sent: Thursday, June 6, 2019 11:11 AM > To: PIKAL Petr ; r-help@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 > 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.0lattice_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.1pillar_1.2.1 > > [9] rlang_0.2.0 lazyeval_0.2.1 rpart_4.1-13 tools_3.5.0 > > [13] munsell_0.4.3compiler_3.5.0 colorspace_1.3-2 tibble_1.4.2 > >> > > __ > > R-help@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/ __ R-help@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.
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 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.0lattice_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.1pillar_1.2.1 [9] rlang_0.2.0 lazyeval_0.2.1 rpart_4.1-13 tools_3.5.0 [13] munsell_0.4.3compiler_3.5.0 colorspace_1.3-2 tibble_1.4.2 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/ [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
[R] debug only top level function
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? 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.0lattice_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.1pillar_1.2.1 [9] rlang_0.2.0 lazyeval_0.2.1 rpart_4.1-13 tools_3.5.0 [13] munsell_0.4.3compiler_3.5.0 colorspace_1.3-2 tibble_1.4.2 > 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/ [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Debug package options
Duncan, Thanks for the help. Since I am the only person using this machine and I couldn’t figure out where to put the option statement aside from: C:\Program Files\R\R-3.1.2\etc In the file Rprofile.site The option that I wanted was: options(debug.font = Consolas 12”) Which allowed me to have the right size font and Tk window to be able to do debugging using the debug package. In case you are interested I use Windows 7 on my Mac via Parallels. Thanks again, Best, KW On Mar 30, 2015, at 2:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 30/03/2015 1:50 PM, Keith S Weintraub wrote: Folks, I would like change some of the options for the Tk window that pops up when using the debug package. I know how to change the options: e.g. options(debug.font = Courier 12 italic”). Is there a way to “preset” these in my environment so when debug starts up I have all the options set up the way I want them? Do I do this in a .First file? Does the .First file have to load the debug package every time I start up R? No need to do my work for me. Just point me to the right doc. See the ?Startup help topic. You probably want to use one of the profile files rather than .First, because .First needs to be in a workspace, and you shouldn't be loading a workspace every time. Duncan Murdoch __ R-help@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.
Re: [R] Debug package options
On 30/03/2015 1:50 PM, Keith S Weintraub wrote: Folks, I would like change some of the options for the Tk window that pops up when using the debug package. I know how to change the options: e.g. options(debug.font = Courier 12 italic”). Is there a way to “preset” these in my environment so when debug starts up I have all the options set up the way I want them? Do I do this in a .First file? Does the .First file have to load the debug package every time I start up R? No need to do my work for me. Just point me to the right doc. See the ?Startup help topic. You probably want to use one of the profile files rather than .First, because .First needs to be in a workspace, and you shouldn't be loading a workspace every time. Duncan Murdoch __ R-help@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.
[R] Debug package options
Folks, I would like change some of the options for the Tk window that pops up when using the debug package. I know how to change the options: e.g. options(debug.font = Courier 12 italic”). Is there a way to “preset” these in my environment so when debug starts up I have all the options set up the way I want them? Do I do this in a .First file? Does the .First file have to load the debug package every time I start up R? No need to do my work for me. Just point me to the right doc. Best, KW __ R-help@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.
[R] debug on lapply
Dear R experts, recently I tried to debug a R function with an internal lapply call. When debugging I seem not to be able to use the n command to debug the inner function called by lapply. How could I achieve this? *For example:* test - function( ) { lapply( 1:3, function( x ) x + 1 ) } debug( test ) *Start debug:* test() debugging in: test() debug bei #1:{ lapply(1:10, function(x) x + 1) } Browse[2] n debug bei #2:lapply(1:10, function(x) x + 1) *The next n does not allow me to inspect the inner function,* *but gives me the result directly:* Browse[2] n exiting from: test() [[1]] [1] 2 [[2]] [1] 3 [[3]] [1] 4 Can anyone help me, please? Kind regards! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug on lapply
Typically when I am debugging an 'lapply', I put a browser call inside the lapply function that is being called and then make sure I 'source' in the code instead of copy/paste -- the copy/paste will use any trailing statements after the lapply call as commands to the browser function. Here is the modified code I used: lapply( 1:3, function( x ){ browser() x + 1 } ) Here is the output from the console after sourcing in the statements above: source('clipboard') Called from: FUN(1:3[[1L]], ...) Browse[1] ls() [1] x Browse[1] x [1] 1 Browse[1] n debug at clipboard#3: x + 1 Browse[2] x [1] 1 Browse[2] n Called from: FUN(1:3[[2L]], ...) Browse[1] x [1] 2 Browse[1] n debug at clipboard#3: x + 1 Browse[2] Called from: FUN(1:3[[3L]], ...) Browse[1] n debug at clipboard#3: x + 1 Browse[2] x [1] 3 Browse[2] n On Tue, Dec 11, 2012 at 1:17 PM, Asis Hallab asis.hal...@gmail.com wrote: Dear R experts, recently I tried to debug a R function with an internal lapply call. When debugging I seem not to be able to use the n command to debug the inner function called by lapply. How could I achieve this? *For example:* test - function( ) { lapply( 1:3, function( x ) x + 1 ) } debug( test ) *Start debug:* test() debugging in: test() debug bei #1:{ lapply(1:10, function(x) x + 1) } Browse[2] n debug bei #2:lapply(1:10, function(x) x + 1) *The next n does not allow me to inspect the inner function,* *but gives me the result directly:* Browse[2] n exiting from: test() [[1]] [1] 2 [[2]] [1] 3 [[3]] [1] 4 Can anyone help me, please? Kind regards! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list 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.
Re: [R] debug on lapply
On 11/12/2012 1:17 PM, Asis Hallab wrote: Dear R experts, recently I tried to debug a R function with an internal lapply call. When debugging I seem not to be able to use the n command to debug the inner function called by lapply. How could I achieve this? Jim gave you one solution. Another is to debug lapply, and when stepping through it, debug(FUN) after it is created on the first line. Jim's method is more convenient if you are particularly interested in a complicated function, this method is better if you are already in the middle of debugging and just want to look at a possibly anonymous function being passed to lapply. Duncan Murdoch *For example:* test - function( ) { lapply( 1:3, function( x ) x + 1 ) } debug( test ) *Start debug:* test() debugging in: test() debug bei #1:{ lapply(1:10, function(x) x + 1) } Browse[2] n debug bei #2:lapply(1:10, function(x) x + 1) *The next n does not allow me to inspect the inner function,* *but gives me the result directly:* Browse[2] n exiting from: test() [[1]] [1] 2 [[2]] [1] 3 [[3]] [1] 4 Can anyone help me, please? Kind regards! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
[R] Debug newbie
Hi! I'm trying to debug the cosmo R package because I'm trying to find out where all the motifs are. I display some of them printing the motif variable but I don't know how to show all of the found motifs in one run. http://www.bioconductor.org/packages/2.10/bioc/html/cosmo.html I think that they must be in line 366 in sites variable in cosmo.R: Code: for (i in 1:com$selNumSites){ site - seqMat[com$alignStarts[i]:(com$alignStarts[i]+com$selWidth-1), com$alignSeqs[i]] sites - c(sites, toString(site)) But when I try to debug it I need first to load the cosmo library, then read the data and then run cosmo: Code: library(cosmo) seqal - system.file(Exfiles/short702k.FASTA, package=cosmo) res - cosmo(seqs=seqal, constraints=None, minW=10, maxW=10, models=TCM ) For debugging line 366 I think I should: Code: library(cosmo) seqal - system.file(Exfiles/short702k.FASTA, package=cosmo) setBreakpoint(cosmo.R,366) res - cosmo(seqs=seqal, constraints=None, minW=10, maxW=10, models=TCM ) But I don't get any value of any variable.. And it doesn't seem to be the easiest way to get the sites variable values.. Ana [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
On 2012-08-10 06:10, Zhang, Peng wrote: Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. There's some information missing here, notably the output from 'sessionInfo()', but I guess this is under GNU/Linux. I can confirm a seg. fault under Fedora FC17 x86_64. Under Windows 7 64-bit, however, we get some further info: library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data + = testdata, level = 2) Initialization... Error in .jnew(glmulti/ModelGenerator, y, .jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 sessionInfo() R version 2.15.1 Patched (2012-08-06 r60178) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 [3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C [5] LC_TIME=Swedish_Sweden.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] glmulti_1.0.4 rJava_0.9-3 So, this doesn't seem to be a bug in R and is thus likely to need the attention of the 'glmulti' package's maintainer. HTH, Henric But I have troubles to extract the exact information from this S4 class to make a simpler example because of my limited knowledge on S4 class. The author of the package is busy at the moment, and does not have time to look into it. Peng On 08/09/2012 10:25 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Aug 9, 2012, at 9:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 9, 2012, at 4:56 PM, Zhang, Peng wrote: Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. 2. Why does the same function behave differently under debug and regular mode? I cannot help you there. Though a reproducible segfault is certainly worth a bug report if you can do so, in debug or regular modes. You may wish to search stackoverflow for tips on how to make a great reproducible example in R. Michael ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
You are right. I am running Arch Linux. However, I obtained a segmentation directly, so didn't know where to find the bug?? library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data= testdata, level = 2) Segmentation fault Is this information Error in .jnew(glmulti/ModelGenerator, y, .jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 only in Windows, or did you see it under Fedora as well? Thank you! Peng BTW: $ uname -a Linux Precision 3.4.7-1-ARCH #1 SMP PREEMPT Sun Jul 29 22:02:56 CEST 2012 x86_64 GNU/Linux sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base On 08/10/2012 09:25 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 06:10, Zhang, Peng wrote: Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. There's some information missing here, notably the output from 'sessionInfo()', but I guess this is under GNU/Linux. I can confirm a seg. fault under Fedora FC17 x86_64. Under Windows 7 64-bit, however, we get some further info: library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data + = testdata, level = 2) Initialization... Error in .jnew(glmulti/ModelGenerator, y, .jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 sessionInfo() R version 2.15.1 Patched (2012-08-06 r60178) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 [3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C [5] LC_TIME=Swedish_Sweden.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] glmulti_1.0.4 rJava_0.9-3 So, this doesn't seem to be a bug in R and is thus likely to need the attention of the 'glmulti' package's maintainer. HTH, Henric But I have troubles to extract the exact information from this S4 class to make a simpler example because of my limited knowledge on S4 class. The author of the package is busy at the moment, and does not have time to look into it. Peng On 08/09/2012 10:25 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Aug 9, 2012, at 9:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 9, 2012, at 4:56 PM, Zhang, Peng wrote: Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. 2. Why does the same function behave differently under debug and regular mode? I cannot help you there. Though a reproducible segfault is certainly worth a bug report if you can do so, in debug or regular modes. You may wish to search stackoverflow for tips on how to make a great reproducible example in R. Michael ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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. ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
On 2012-08-10 15:42, Zhang, Peng wrote: You are right. I am running Arch Linux. However, I obtained a segmentation directly, so didn't know where to find the bug?? library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data= testdata, level = 2) Segmentation fault Is this information Error in .jnew(glmulti/ModelGenerator, y, jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 only in Windows, or did you see it under Fedora as well? Windows only. Fedora just returned Segmentation fault. //Henric Thank you! Peng BTW: $ uname -a Linux Precision 3.4.7-1-ARCH #1 SMP PREEMPT Sun Jul 29 22:02:56 CEST 2012 x86_64 GNU/Linux sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base On 08/10/2012 09:25 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 06:10, Zhang, Peng wrote: Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. There's some information missing here, notably the output from 'sessionInfo()', but I guess this is under GNU/Linux. I can confirm a seg. fault under Fedora FC17 x86_64. Under Windows 7 64-bit, however, we get some further info: library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data + = testdata, level = 2) Initialization... Error in .jnew(glmulti/ModelGenerator, y, .jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 sessionInfo() R version 2.15.1 Patched (2012-08-06 r60178) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 [3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C [5] LC_TIME=Swedish_Sweden.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] glmulti_1.0.4 rJava_0.9-3 So, this doesn't seem to be a bug in R and is thus likely to need the attention of the 'glmulti' package's maintainer. HTH, Henric But I have troubles to extract the exact information from this S4 class to make a simpler example because of my limited knowledge on S4 class. The author of the package is busy at the moment, and does not have time to look into it. Peng On 08/09/2012 10:25 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Aug 9, 2012, at 9:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 9, 2012, at 4:56 PM, Zhang, Peng wrote: Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. 2. Why does the same function behave differently under debug and regular mode? I cannot help you there. Though a reproducible segfault is certainly worth a bug report if you can do so, in debug or regular modes. You may wish to search stackoverflow for tips on how to make a great reproducible example in R. Michael ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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. ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
Thanks! It is interesting that Windows has pointed the problem to Java. So it is probable that how I did my debug led me to the wrong direction. Since I was unsure how to debug S4 class, I copied the source implement R function from glmulti package into my testing program. The segmentation fault will appear when I step to neotete = terms(as.formula(paste(h~,paste(preds, collapse=*. That is why I have asked my initial question on the board. The more interesting thing is that if I don't run library(glmulti), but just the following lines, I won't have problem when I stepped to that terms function. I am totally lost. It is not clear to me how to debug S4 class. Best, Peng ### beginning library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti = function(y, xr, data, exclude, name, intercept, marginality , bunch, chunk, chunks, level, minsize, maxsize, minK, maxK, method,crit,confsetsize,popsize,mutrate, sexrate,imm, plotty, report, deltaM, deltaB, conseq, fitfunction, resumefile, includeobjects, ...) { if (missing(data)) tete = terms(y) else tete = terms(y, data=data) oo = attr(tete,order) dep = as.character(attr(tete,variables))[2] int = attr(tete,intercept) preds = as.character(attr(tete,variables))[-(1:2)] if (level==2 max(oo)1) { # get all possible interactions interac = attr(tete,term.labels)[oo==2] neotete = terms(as.formula(paste(h~,paste(preds, collapse=* neointerac= attr(neotete,term.labels)[attr(neotete,order)==2] # get exclusions for (i in interac) neointerac=neointerac[neointerac!=i] # same for main effects mama = attr(tete,term.labels)[oo==1] exma = preds for (j in mama) exma = exma[exma!=j] exma = c(exma,neointerac) } else { preds = attr(tete,term.labels)[oo==1] exma=c(1) } call = match.call() call[[match(y, names(call))]] = dep call[[length(names(call))+1]] = preds names(call)[length(names(call))] =xr call[[length(names(call))+1]] = exma names(call)[length(names(call))] =exclude if (missing(data)) { call[[length(names(call))+1]] = environment(y) names(call)[length(names(call))] =data } eval(call) } debug(glmulti) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, xr=NULL, data = testdata, level = 2) ###end On 08/10/2012 11:47 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 15:42, Zhang, Peng wrote: You are right. I am running Arch Linux. However, I obtained a segmentation directly, so didn't know where to find the bug?? library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data= testdata, level = 2) Segmentation fault Is this information Error in .jnew(glmulti/ModelGenerator, y, jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 only in Windows, or did you see it under Fedora as well? Windows only. Fedora just returned Segmentation fault. //Henric Thank you! Peng BTW: $ uname -a Linux Precision 3.4.7-1-ARCH #1 SMP PREEMPT Sun Jul 29 22:02:56 CEST 2012 x86_64 GNU/Linux sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base On 08/10/2012 09:25 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 06:10, Zhang, Peng wrote: Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. There's some information missing here, notably the output from 'sessionInfo()', but I guess this is under GNU/Linux. I can confirm a seg. fault under Fedora FC17 x86_64. Under Windows 7 64-bit, however, we get some further info: library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data + = testdata, level = 2) Initialization... Error in .jnew(glmulti/ModelGenerator, y, .jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 sessionInfo() R version 2.15.1 Patched (2012-08-06 r60178) Platform:
Re: [R] debug vs regular mode
Not to spoil your fun, but this is getting a bit off-topic for R-help. If you wish to continue the debugging process in public, I think you should move to R-devel. Also, it sounds like the problem is in the glmulti package, so you might want to involve its maintainer at some point. -pd On Aug 10, 2012, at 19:51 , Zhang, Peng wrote: Thanks! It is interesting that Windows has pointed the problem to Java. So it is probable that how I did my debug led me to the wrong direction. Since I was unsure how to debug S4 class, I copied the source implement R function from glmulti package into my testing program. The segmentation fault will appear when I step to neotete = terms(as.formula(paste(h~,paste(preds, collapse=*. That is why I have asked my initial question on the board. The more interesting thing is that if I don't run library(glmulti), but just the following lines, I won't have problem when I stepped to that terms function. I am totally lost. It is not clear to me how to debug S4 class. Best, Peng ### beginning library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti = function(y, xr, data, exclude, name, intercept, marginality , bunch, chunk, chunks, level, minsize, maxsize, minK, maxK, method,crit,confsetsize,popsize,mutrate, sexrate,imm, plotty, report, deltaM, deltaB, conseq, fitfunction, resumefile, includeobjects, ...) { if (missing(data)) tete = terms(y) else tete = terms(y, data=data) oo = attr(tete,order) dep = as.character(attr(tete,variables))[2] int = attr(tete,intercept) preds = as.character(attr(tete,variables))[-(1:2)] if (level==2 max(oo)1) { # get all possible interactions interac = attr(tete,term.labels)[oo==2] neotete = terms(as.formula(paste(h~,paste(preds, collapse=* neointerac= attr(neotete,term.labels)[attr(neotete,order)==2] # get exclusions for (i in interac) neointerac=neointerac[neointerac!=i] # same for main effects mama = attr(tete,term.labels)[oo==1] exma = preds for (j in mama) exma = exma[exma!=j] exma = c(exma,neointerac) } else { preds = attr(tete,term.labels)[oo==1] exma=c(1) } call = match.call() call[[match(y, names(call))]] = dep call[[length(names(call))+1]] = preds names(call)[length(names(call))] =xr call[[length(names(call))+1]] = exma names(call)[length(names(call))] =exclude if (missing(data)) { call[[length(names(call))+1]] = environment(y) names(call)[length(names(call))] =data } eval(call) } debug(glmulti) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, xr=NULL, data = testdata, level = 2) ###end On 08/10/2012 11:47 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 15:42, Zhang, Peng wrote: You are right. I am running Arch Linux. However, I obtained a segmentation directly, so didn't know where to find the bug?? library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data= testdata, level = 2) Segmentation fault Is this information Error in .jnew(glmulti/ModelGenerator, y, jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 only in Windows, or did you see it under Fedora as well? Windows only. Fedora just returned Segmentation fault. //Henric Thank you! Peng BTW: $ uname -a Linux Precision 3.4.7-1-ARCH #1 SMP PREEMPT Sun Jul 29 22:02:56 CEST 2012 x86_64 GNU/Linux sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base On 08/10/2012 09:25 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 06:10, Zhang, Peng wrote: Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. There's some information missing here, notably the output from 'sessionInfo()', but I guess this is under GNU/Linux. I can confirm a seg. fault under Fedora FC17 x86_64. Under Windows 7 64-bit, however, we get some further info: library(glmulti) Loading required package: rJava
Re: [R] debug vs regular mode
On Aug 10, 2012, at 21:23 , Zhang, Peng wrote: Ok. I will stop here. I have just created a bug report. https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15013 ...which is exactly what you should NOT do, if the bug is likely to live in a contributed package!! -pd If anyone is interested, please see if you can reproduce it. Thanks, Peng On 08/10/2012 03:04 PM, peter dalgaard wrote: Not to spoil your fun, but this is getting a bit off-topic for R-help. If you wish to continue the debugging process in public, I think you should move to R-devel. Also, it sounds like the problem is in the glmulti package, so you might want to involve its maintainer at some point. -pd [much snipped] -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
Ok. I will stop here. I have just created a bug report. https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15013 If anyone is interested, please see if you can reproduce it. Thanks, Peng On 08/10/2012 03:04 PM, peter dalgaard wrote: Not to spoil your fun, but this is getting a bit off-topic for R-help. If you wish to continue the debugging process in public, I think you should move to R-devel. Also, it sounds like the problem is in the glmulti package, so you might want to involve its maintainer at some point. -pd On Aug 10, 2012, at 19:51 , Zhang, Peng wrote: Thanks! It is interesting that Windows has pointed the problem to Java. So it is probable that how I did my debug led me to the wrong direction. Since I was unsure how to debug S4 class, I copied the source implement R function from glmulti package into my testing program. The segmentation fault will appear when I step to neotete = terms(as.formula(paste(h~,paste(preds, collapse=*. That is why I have asked my initial question on the board. The more interesting thing is that if I don't run library(glmulti), but just the following lines, I won't have problem when I stepped to that terms function. I am totally lost. It is not clear to me how to debug S4 class. Best, Peng ### beginning library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti = function(y, xr, data, exclude, name, intercept, marginality , bunch, chunk, chunks, level, minsize, maxsize, minK, maxK, method,crit,confsetsize,popsize,mutrate, sexrate,imm, plotty, report, deltaM, deltaB, conseq, fitfunction, resumefile, includeobjects, ...) { if (missing(data)) tete = terms(y) else tete = terms(y, data=data) oo = attr(tete,order) dep = as.character(attr(tete,variables))[2] int = attr(tete,intercept) preds = as.character(attr(tete,variables))[-(1:2)] if (level==2 max(oo)1) { # get all possible interactions interac = attr(tete,term.labels)[oo==2] neotete = terms(as.formula(paste(h~,paste(preds, collapse=* neointerac= attr(neotete,term.labels)[attr(neotete,order)==2] # get exclusions for (i in interac) neointerac=neointerac[neointerac!=i] # same for main effects mama = attr(tete,term.labels)[oo==1] exma = preds for (j in mama) exma = exma[exma!=j] exma = c(exma,neointerac) } else { preds = attr(tete,term.labels)[oo==1] exma=c(1) } call = match.call() call[[match(y, names(call))]] = dep call[[length(names(call))+1]] = preds names(call)[length(names(call))] =xr call[[length(names(call))+1]] = exma names(call)[length(names(call))] =exclude if (missing(data)) { call[[length(names(call))+1]] = environment(y) names(call)[length(names(call))] =data } eval(call) } debug(glmulti) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, xr=NULL, data = testdata, level = 2) ###end On 08/10/2012 11:47 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 15:42, Zhang, Peng wrote: You are right. I am running Arch Linux. However, I obtained a segmentation directly, so didn't know where to find the bug?? library(glmulti) Loading required package: rJava testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data= testdata, level = 2) Segmentation fault Is this information Error in .jnew(glmulti/ModelGenerator, y, jarray(xc), .jarray(xq), : java.lang.ArrayIndexOutOfBoundsException: 15 only in Windows, or did you see it under Fedora as well? Windows only. Fedora just returned Segmentation fault. //Henric Thank you! Peng BTW: $ uname -a Linux Precision 3.4.7-1-ARCH #1 SMP PREEMPT Sun Jul 29 22:02:56 CEST 2012 x86_64 GNU/Linux sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base On 08/10/2012 09:25 AM, Henric (Nilsson) Winell wrote: On 2012-08-10 06:10, Zhang, Peng wrote: Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. There's some information missing here, notably the
Re: [R] debug vs regular mode
If you read my bug report, I just ran the same thing on both regular mode and debug mode. That is why I think it is related with R base, though there might be some other bugs related with glmulti or rJava. Peng On 08/10/2012 04:03 PM, peter dalgaard wrote: On Aug 10, 2012, at 21:23 , Zhang, Peng wrote: Ok. I will stop here. I have just created a bug report. https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15013 ...which is exactly what you should NOT do, if the bug is likely to live in a contributed package!! -pd If anyone is interested, please see if you can reproduce it. Thanks, Peng On 08/10/2012 03:04 PM, peter dalgaard wrote: Not to spoil your fun, but this is getting a bit off-topic for R-help. If you wish to continue the debugging process in public, I think you should move to R-devel. Also, it sounds like the problem is in the glmulti package, so you might want to involve its maintainer at some point. -pd [much snipped] ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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.
[R] debug vs regular mode
Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. When I reached terms(Y~X1*X2*...*X16), I would then have segmentation fault. However, if I just ran this under regular R interactive mode, it would be fine though taking long time. My questions are: 1. Is there a known limit of terms for a formula? 2. Why does the same function behave differently under debug and regular mode? Thank you! Best, Peng ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
On Aug 9, 2012, at 4:56 PM, Zhang, Peng wrote: Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. When I reached terms(Y~X1*X2*...*X16), I would then have segmentation fault. However, if I just ran this under regular R interactive mode, it would be fine though taking long time. My questions are: 1. Is there a known limit of terms for a formula? I think so. I seem to remember it was something around 500 characters, but was raised a couple of years ago. This is a 2010 extract of a posting by the indomitable Prof Ripley: R-devel: • The previously almost undocumented limit of 256 bytes on a symbol name has been raised to 10,000 bytes (a sanity check). Long symbol names can sometimes occur when deparsing expressions (for example, in model.frame). Found with a MarkMail search with this strategy: list:org.r-project.r-devel maximum length of formula Subject:Re: [Rd] model.frame problem From:Prof Brian Ripley (rip...@stats.ox.ac.uk) Date:Nov 3, 2010 1:37:50 pm List:org.r-project.r-devel 2. Why does the same function behave differently under debug and regular mode? I cannot help you there. -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
On Aug 9, 2012, at 9:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 9, 2012, at 4:56 PM, Zhang, Peng wrote: Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. 2. Why does the same function behave differently under debug and regular mode? I cannot help you there. Though a reproducible segfault is certainly worth a bug report if you can do so, in debug or regular modes. You may wish to search stackoverflow for tips on how to make a great reproducible example in R. Michael __ R-help@r-project.org mailing list 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.
Re: [R] debug vs regular mode
Thanks to both for your reply. library(glmulti) testdata = cbind(Y=rnorm(100), data.frame(matrix(rnorm(100*50), ncol = 50))) glmulti(Y~(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12+X13+X14+X15)*X16, data = testdata, level = 2) This is reproducible to get a segmentation fault. But I have troubles to extract the exact information from this S4 class to make a simpler example because of my limited knowledge on S4 class. The author of the package is busy at the moment, and does not have time to look into it. Peng On 08/09/2012 10:25 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Aug 9, 2012, at 9:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 9, 2012, at 4:56 PM, Zhang, Peng wrote: Dear all, I had a R segmentation fault, and then invoked debug mode and ran step by step. 2. Why does the same function behave differently under debug and regular mode? I cannot help you there. Though a reproducible segfault is certainly worth a bug report if you can do so, in debug or regular modes. You may wish to search stackoverflow for tips on how to make a great reproducible example in R. Michael ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list 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.
Re: [R] debug in a loop
On 12-02-10 12:48 PM, Justin Haynes wrote: You can add if(is.na(tab[i])) browser() or if(is.na(tab[i])) break see inline You can also do this temporarily. Supposing that you used source(foo.R) to enter a function with that code in it, and you want the check on line 10, you'd enter setBreakpoint(foo.R#10, tracer=quote(if(is.na(tab[i])) browser())) Duncan Murdoch On Fri, Feb 10, 2012 at 7:22 AM, ikuzarraz...@hotmail.fr wrote: Hi, I'd like to debug in a loop (using debug() and browser() etc but not print() ). I'am looking for the first occurence of NA. For instance: tab = c(1:300) tab[250] = NA len = length(tab) for (i in 1:len){ if(i != len){ if(is.na(tab[i])) browser() tab[i] = tab[i]+tab[i+1] } } I do not want to do Browse[2] n for each step ... I'd like to declare a browser() in the loop with a condition. But how to write stop running when you encounter NA ? Thanks for your help -- View this message in context: http://r.789695.n4.nabble.com/debug-in-a-loop-tp4376563p4376563.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
[R] debug in a loop
Hi, I'd like to debug in a loop (using debug() and browser() etc but not print() ). I'am looking for the first occurence of NA. For instance: tab = c(1:300) tab[250] = NA len = length(tab) for (i in 1:len){ if(i != len){ tab[i] = tab[i]+tab[i+1] } } I do not want to do Browse[2] n for each step ... I'd like to declare a browser() in the loop with a condition. But how to write stop running when you encounter NA ? Thanks for your help -- View this message in context: http://r.789695.n4.nabble.com/debug-in-a-loop-tp4376563p4376563.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] debug in a loop
You can add if(is.na(tab[i])) browser() or if(is.na(tab[i])) break see inline On Fri, Feb 10, 2012 at 7:22 AM, ikuzar raz...@hotmail.fr wrote: Hi, I'd like to debug in a loop (using debug() and browser() etc but not print() ). I'am looking for the first occurence of NA. For instance: tab = c(1:300) tab[250] = NA len = length(tab) for (i in 1:len){ if(i != len){ if(is.na(tab[i])) browser() tab[i] = tab[i]+tab[i+1] } } I do not want to do Browse[2] n for each step ... I'd like to declare a browser() in the loop with a condition. But how to write stop running when you encounter NA ? Thanks for your help -- View this message in context: http://r.789695.n4.nabble.com/debug-in-a-loop-tp4376563p4376563.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
[R] debug package: mtrace fails
Hi all, Since three month ago I started working with R professionally, I never did it before, so I am such a newbie. I am having some problems using the 'debug' package. I love this package, but most of the times I wanna use it it just fails :P When typing at prompt 'mtrace(myfunct)' most of the times I get the following error: Error in x[[i]] : subscript out of bounds I can't understand whats happening and I couldn't find any help surfing the net. I have the feeling it might be because of my coding style or something similar. Any help will be highly appreciated :) Thanks in advance! see ya -- View this message in context: http://r.789695.n4.nabble.com/debug-package-mtrace-fails-tp4323546p4323546.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] debug package: mtrace fails
Hi Deivit, Can you offer a self contained example of r code when the function fails for you? Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Tue, Jan 24, 2012 at 1:40 PM, deivit david.cass...@transmuralbiotech.com wrote: Hi all, Since three month ago I started working with R professionally, I never did it before, so I am such a newbie. I am having some problems using the 'debug' package. I love this package, but most of the times I wanna use it it just fails :P When typing at prompt 'mtrace(myfunct)' most of the times I get the following error: Error in x[[i]] : subscript out of bounds I can't understand whats happening and I couldn't find any help surfing the net. I have the feeling it might be because of my coding style or something similar. Any help will be highly appreciated :) Thanks in advance! see ya -- View this message in context: http://r.789695.n4.nabble.com/debug-package-mtrace-fails-tp4323546p4323546.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug package: mtrace fails
I'll try, Here is a piece of code it fails for me, the error I get is always the same, and it happens in most of my functions. The problem is always the same trying to execute 'mtrace'. Thanks! --- execution -- mtrace(index_remap) Error in x[[i]] : subscript out of bounds --- code --- index_remap - function (idx_relation=NULL, idx_vector=NULL, undo=FALSE) { if ((! any(duplicated(idx_vector))) all(idx_vector %in% idx_relation)) { updated_idx - {} for ( i in 1:length(idx_vector) ) { if (undo == FALSE) { updated_idx - c(updated_idx, which (idx_relation == idx_vector[i])) } else { updated_idx - c(updated_idx, idx_relation[idx_vector[i]]) } } return (updated_idx) } else { error_msg(Some error message) } } error_msg = function ( msg=NULL) { cat(style(msg,fg=red),\n) } -- View this message in context: http://r.789695.n4.nabble.com/debug-package-mtrace-fails-tp4323546p4324179.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] debug R code
Hi List, I have a question regarding debug R code. I know I can use debug(fuction_name) and when code runs to that point, it will go to debugger. My question is inside debugger, how to stop a code at a specified line. For example, in C (gdb or dbx debugger) I can run stop at 123 (stop at line 123) or 'b 123' (break at line 123). Is there any similar commend in R debugger? Thanks. HXD [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug R code
On 11-06-03 4:49 PM, Hui Du wrote: Hi List, I have a question regarding debug R code. I know I can use debug(fuction_name) and when code runs to that point, it will go to debugger. My question is inside debugger, how to stop a code at a specified line. For example, in C (gdb or dbx debugger) I can run stop at 123 (stop at line 123) or 'b 123' (break at line 123). Is there any similar commend in R debugger? See ?setBreakpoint. You can set a breakpoint from within the browser, or before you run your function. ?trace gives full details on all the (many) options. Duncan Murdoch __ R-help@r-project.org mailing list 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.
Re: [R] debug R device plot
Not sure if you ever figured this out, but I was just directed to this post. You need to look for a file (it may not be in your project directory) that contains ___LOCK in its file name and delete it. filehash creates this to prevent multiple writes to the same file at the same time and somehow it did not get removed correctly. tikzDevice uses the filehash package to cache font metrics and it must have gotten interrupted. -Cameron -- View this message in context: http://r.789695.n4.nabble.com/debug-R-device-plot-tp3403638p3545415.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] debug R device plot
cameron.bracken wrote: You need to look for a file (it may not be in your project directory) that contains ___LOCK in its file name and delete it. Specifically, the rogue lockfile should be in the same directory as options('tikzMetricsDictionary'). Or, if you haven't set a permanent location for the metrics dictionary, it will be in a temporary directory. The tikzDevice prints out a status message with the location of the temporary dictionary whenever it has to create one. - Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/debug-R-device-plot-tp3403638p3545664.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
[R] debug R device plot
Hi there, I was doing great with R, ggplot and tikzDevice, when suddenly it stopped working. I can do a plot just fine on the R online graphics device. I can also open a tikzdevice via tikz(). However, the plot (both ggplot and R graphics plot) call leads to the error: createLockFile(lockname): cannot create lock file I see that this is related to my OS, namely Ubuntu 10.04. I already checked if I have write access to /var/lock via touch /var/lock/test rm -f /var/lock/test which gave no errors... Now my actual question: How can I inspect which file R wants to create? It fails both when called from inside emacs via ESS mode and when called from the command line. I am out of ideas... Any advice on how to inspect what is going on here? Thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug biglm response error on bigglm model
Thank you, Greg. The issue was in the simulation logic, where one of the values was not changing correctly for some iterations... On Jan 10, 3:20 pm, Greg Snow greg.s...@imail.org wrote: Not sure, but one possible candidate problem is that in your simulations one iteration ended up with fewer levels of a factor than the overall dataset and that caused the error. There is no recode function in the default packages, there are at least 6 recode functions in other packages, we cannot tell which you were using from the code below. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Mike Harwood Sent: Monday, January 10, 2011 6:29 AM To: r-h...@r-project.org Subject: [R] debug biglm response error on bigglm model G'morning What does the error message Error in x %*% coef(object) : non- conformable arguments indicate when calculating the response values for newdata with a model from bigglm (in package biglm), and how can I debug it? I am attempting to do Monte Carlo simulations, which may explain the loop in the code that follows. After the code I have included the output, which shows that the simulations are changing the response and input values, and that there are not any atypical values for the factors in the seventh iteration. At the end of the output is the aforementioned error message. Finally, I have included the model from biglm. Thanks in advance! Code: === iter - nrow(nov.2010) predict.nov.2011 - vector(mode='numeric', length=iter) for (i in 1:iter) { iter.df - nov.2010 ##-- Update values of dynamic variables -- iter.df$age - iter.df$age + 12 iter.df$pct_utilize - iter.df$pct_utilize + mc.util.delta[i] iter.df$updated_varname1 - ceiling(iter.df$updated_varname1 + mc.varname1.delta[i]) if(iter.df$state==WI) iter.df$varname3 - iter.df$varname3 + mc.wi.varname3.delta[i] if(iter.df$state==MN) iter.df$varname3 - iter.df$varname3 + mc.mn.varname3.delta[i] if(iter.df$state==IL) iter.df$varname3 - iter.df$varname3 + mc.il.varname3.delta[i] if(iter.df$state==US) iter.df$varname3 - iter.df$varname3 + mc.us.varname3.delta[i] ##--- Bin Variables -- iter.df$bin_varname1 - as.factor(recode(iter.df$updated_varname1, 300:499 = '300 - 499'; 500:549 = '500 - 549'; 550:599 = '550 - 599'; 600:649 = '600 - 649'; 650:699 = '650 - 699'; 700:749 = '700 - 749'; 750:799 = '750 - 799'; 800:849 = 'GE 800'; else = 'missing'; )) iter.df$bin_age - as.factor(recode(iter.df$age, 0:23 = ' 24mo.'; 24:72 = '24 - 72mo.'; 72:300 = '72 - 300mo'; else = 'missing'; )) iter.df$bin_util - as.factor(recode(iter.df$pct_utilize, 0.0:0.2 = ' 0 - 20%'; 0.2:0.4 = ' 20 - 40%'; 0.4:0.6 = ' 40 - 60%'; 0.6:0.8 = ' 60 - 80%'; 0.8:1.0 = ' 80 - 100%'; 1.0:1.2 = '100 - 120%'; else = 'missing'; )) iter.df$bin_varname2 - as.factor(recode(iter.df$varname2_prop, 0:70 = ' 70%'; 70:85 = ' 70 - 85%'; 85:95 = ' 85 - 95%'; 95:110 = '95 - 110%'; else = 'missing'; )) iter.df$bin_varname1 - relevel(iter.df$bin_varname1, 'missing') iter.df$bin_age - relevel(iter.df$bin_age, 'missing') iter.df$bin_util - relevel(iter.df$bin_util, 'missing') iter.df$bin_varname2 - relevel(iter.df$bin_varname2, 'missing') #~ print(head(iter.df)) if (i=6 i=8){ print('-') browser() print(i) print(table(iter.df$bin_varname1)) print(table(iter.df$bin_age)) print(table(iter.df$bin_util)) print(table(iter.df$bin_varname2)) #~ debug(predict.nov.2011[i] - #~ sum(predict(logModel.1, newdata=iter.df, type='response'))) } predict.nov.2011[i] - sum(predict(logModel.1, newdata=iter.df, type='response')) print(predict.nov.2011[i]) } Output == [1] 36.56073 [1] 561.4516 [1] 4.83483 [1] 5.01398 [1] 7.984146 [1] - Called from: top level Browse[1] [1] 6 missing 300 - 499 500 - 549 550 - 599 600 - 649 650 - 699 700 - 749 750 - 799 GE 800 842 283 690 1094 1695 3404 6659 18374 21562 missing 24mo. 24 - 72mo. 72 - 300mo 16 2997 19709 31881 missing 0 - 20% 20 - 40% 40 - 60% 60 - 80% 80 - 100% 100 - 120% 17906
[R] debug biglm response error on bigglm model
G'morning What does the error message Error in x %*% coef(object) : non- conformable arguments indicate when calculating the response values for newdata with a model from bigglm (in package biglm), and how can I debug it? I am attempting to do Monte Carlo simulations, which may explain the loop in the code that follows. After the code I have included the output, which shows that the simulations are changing the response and input values, and that there are not any atypical values for the factors in the seventh iteration. At the end of the output is the aforementioned error message. Finally, I have included the model from biglm. Thanks in advance! Code: === iter - nrow(nov.2010) predict.nov.2011 - vector(mode='numeric', length=iter) for (i in 1:iter) { iter.df - nov.2010 ##-- Update values of dynamic variables -- iter.df$age - iter.df$age + 12 iter.df$pct_utilize - iter.df$pct_utilize + mc.util.delta[i] iter.df$updated_varname1 - ceiling(iter.df$updated_varname1 + mc.varname1.delta[i]) if(iter.df$state==WI) iter.df$varname3 - iter.df$varname3 + mc.wi.varname3.delta[i] if(iter.df$state==MN) iter.df$varname3 - iter.df$varname3 + mc.mn.varname3.delta[i] if(iter.df$state==IL) iter.df$varname3 - iter.df$varname3 + mc.il.varname3.delta[i] if(iter.df$state==US) iter.df$varname3 - iter.df$varname3 + mc.us.varname3.delta[i] ##--- Bin Variables -- iter.df$bin_varname1 - as.factor(recode(iter.df$updated_varname1, 300:499 = '300 - 499'; 500:549 = '500 - 549'; 550:599 = '550 - 599'; 600:649 = '600 - 649'; 650:699 = '650 - 699'; 700:749 = '700 - 749'; 750:799 = '750 - 799'; 800:849 = 'GE 800'; else= 'missing'; )) iter.df$bin_age - as.factor(recode(iter.df$age, 0:23 = ' 24mo.'; 24:72 = '24 - 72mo.'; 72:300 = '72 - 300mo'; else = 'missing'; )) iter.df$bin_util - as.factor(recode(iter.df$pct_utilize, 0.0:0.2 = ' 0 - 20%'; 0.2:0.4 = ' 20 - 40%'; 0.4:0.6 = ' 40 - 60%'; 0.6:0.8 = ' 60 - 80%'; 0.8:1.0 = ' 80 - 100%'; 1.0:1.2 = '100 - 120%'; else= 'missing'; )) iter.df$bin_varname2 - as.factor(recode(iter.df$varname2_prop, 0:70 = ' 70%'; 70:85 = ' 70 - 85%'; 85:95 = ' 85 - 95%'; 95:110 = '95 - 110%'; else = 'missing'; )) iter.df$bin_varname1 - relevel(iter.df$bin_varname1, 'missing') iter.df$bin_age - relevel(iter.df$bin_age, 'missing') iter.df$bin_util - relevel(iter.df$bin_util, 'missing') iter.df$bin_varname2 - relevel(iter.df$bin_varname2, 'missing') #~ print(head(iter.df)) if (i=6 i=8){ print('-') browser() print(i) print(table(iter.df$bin_varname1)) print(table(iter.df$bin_age)) print(table(iter.df$bin_util)) print(table(iter.df$bin_varname2)) #~ debug(predict.nov.2011[i] - #~ sum(predict(logModel.1, newdata=iter.df, type='response'))) } predict.nov.2011[i] - sum(predict(logModel.1, newdata=iter.df, type='response')) print(predict.nov.2011[i]) } Output == [1] 36.56073 [1] 561.4516 [1] 4.83483 [1] 5.01398 [1] 7.984146 [1] - Called from: top level Browse[1] [1] 6 missing 300 - 499 500 - 549 550 - 599 600 - 649 650 - 699 700 - 749 750 - 799GE 800 842 283 690 1094 1695 3404 6659 18374 21562 missing 24mo. 24 - 72mo. 72 - 300mo 16 2997 19709 31881 missing0 - 20% 20 - 40% 40 - 60% 60 - 80% 80 - 100% 100 - 120% 17906 4832 4599 5154 7205 14865 42 missing 70% 70 - 85% 85 - 95% 95 - 110% 10423 19429 10568 8350 5833 [1] 11.04090 [1] - Called from: top level Browse[1] [1] 7 missing 300 - 499 500 - 549 550 - 599 600 - 649 650 - 699 700 - 749 750 - 799 847 909 1059 1586 3214 6304 16349 24335 missing 24mo. 24 - 72mo. 72 - 300mo 16 2997 19709 31881 missing0 - 20% 20 - 40% 40 - 60% 60 - 80% 80 - 100% 100 - 120% 17145 4972 4617 5020 6634 16139 76 missing 70% 70 - 85% 85 - 95% 95 - 110% 10423 19429 10568 8350 5833 Error in x %*% coef(object) : non-conformable arguments Model === Large data regression model: bigglm(outcome ~ bin_varname1 + bin_varname2 + bin_age + bin_util + state + varname3 + varname3:state, family = binomial(link = logit), data = dev.data, maxit = 75, sandwich = FALSE) Sample size = 1372250 __ R-help@r-project.org mailing list
Re: [R] debug biglm response error on bigglm model
Not sure, but one possible candidate problem is that in your simulations one iteration ended up with fewer levels of a factor than the overall dataset and that caused the error. There is no recode function in the default packages, there are at least 6 recode functions in other packages, we cannot tell which you were using from the code below. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Mike Harwood Sent: Monday, January 10, 2011 6:29 AM To: r-help@r-project.org Subject: [R] debug biglm response error on bigglm model G'morning What does the error message Error in x %*% coef(object) : non- conformable arguments indicate when calculating the response values for newdata with a model from bigglm (in package biglm), and how can I debug it? I am attempting to do Monte Carlo simulations, which may explain the loop in the code that follows. After the code I have included the output, which shows that the simulations are changing the response and input values, and that there are not any atypical values for the factors in the seventh iteration. At the end of the output is the aforementioned error message. Finally, I have included the model from biglm. Thanks in advance! Code: === iter - nrow(nov.2010) predict.nov.2011 - vector(mode='numeric', length=iter) for (i in 1:iter) { iter.df - nov.2010 ##-- Update values of dynamic variables -- iter.df$age - iter.df$age + 12 iter.df$pct_utilize - iter.df$pct_utilize + mc.util.delta[i] iter.df$updated_varname1 - ceiling(iter.df$updated_varname1 + mc.varname1.delta[i]) if(iter.df$state==WI) iter.df$varname3 - iter.df$varname3 + mc.wi.varname3.delta[i] if(iter.df$state==MN) iter.df$varname3 - iter.df$varname3 + mc.mn.varname3.delta[i] if(iter.df$state==IL) iter.df$varname3 - iter.df$varname3 + mc.il.varname3.delta[i] if(iter.df$state==US) iter.df$varname3 - iter.df$varname3 + mc.us.varname3.delta[i] ##--- Bin Variables -- iter.df$bin_varname1 - as.factor(recode(iter.df$updated_varname1, 300:499 = '300 - 499'; 500:549 = '500 - 549'; 550:599 = '550 - 599'; 600:649 = '600 - 649'; 650:699 = '650 - 699'; 700:749 = '700 - 749'; 750:799 = '750 - 799'; 800:849 = 'GE 800'; else= 'missing'; )) iter.df$bin_age - as.factor(recode(iter.df$age, 0:23 = ' 24mo.'; 24:72 = '24 - 72mo.'; 72:300 = '72 - 300mo'; else = 'missing'; )) iter.df$bin_util - as.factor(recode(iter.df$pct_utilize, 0.0:0.2 = ' 0 - 20%'; 0.2:0.4 = ' 20 - 40%'; 0.4:0.6 = ' 40 - 60%'; 0.6:0.8 = ' 60 - 80%'; 0.8:1.0 = ' 80 - 100%'; 1.0:1.2 = '100 - 120%'; else= 'missing'; )) iter.df$bin_varname2 - as.factor(recode(iter.df$varname2_prop, 0:70 = ' 70%'; 70:85 = ' 70 - 85%'; 85:95 = ' 85 - 95%'; 95:110 = '95 - 110%'; else = 'missing'; )) iter.df$bin_varname1 - relevel(iter.df$bin_varname1, 'missing') iter.df$bin_age - relevel(iter.df$bin_age, 'missing') iter.df$bin_util - relevel(iter.df$bin_util, 'missing') iter.df$bin_varname2 - relevel(iter.df$bin_varname2, 'missing') #~ print(head(iter.df)) if (i=6 i=8){ print('-') browser() print(i) print(table(iter.df$bin_varname1)) print(table(iter.df$bin_age)) print(table(iter.df$bin_util)) print(table(iter.df$bin_varname2)) #~ debug(predict.nov.2011[i] - #~ sum(predict(logModel.1, newdata=iter.df, type='response'))) } predict.nov.2011[i] - sum(predict(logModel.1, newdata=iter.df, type='response')) print(predict.nov.2011[i]) } Output == [1] 36.56073 [1] 561.4516 [1] 4.83483 [1] 5.01398 [1] 7.984146 [1] - Called from: top level Browse[1] [1] 6 missing 300 - 499 500 - 549 550 - 599 600 - 649 650 - 699 700 - 749 750 - 799GE 800 842 283 690 1094 1695 3404 6659 18374 21562 missing 24mo. 24 - 72mo. 72 - 300mo 16 2997 19709 31881 missing0 - 20% 20 - 40% 40 - 60% 60 - 80% 80 - 100% 100 - 120% 17906 4832 4599 5154 7205 14865 42 missing 70% 70 - 85% 85 - 95% 95 - 110% 10423 19429 10568 8350 5833 [1] 11.04090 [1] - Called from: top level Browse[1] [1] 7 missing 300 - 499 500 - 549 550 - 599
Re: [R] debug an error that incapacitates R?
-Original Message- From: Liviu Andronic [mailto:landronim...@gmail.com] Sent: Sunday, December 13, 2009 4:05 AM To: Duncan Murdoch Cc: r-help@r-project.org Help Subject: Re: [R] debug an error that incapacitates R? Hello And thank you for the quick answer. On 12/13/09, Duncan Murdoch murd...@stats.uwo.ca wrote: I think you need to go back to old-fashioned debugging methods. Identify the line the triggers the error, by using debug() and single stepping through sosInit(), or by adding print() or cat() statements to it (or setting tracepoints with trace()), and seeing how many succeed before things go bad. Experimenting with browser() and subsequently with the step-through debug() I managed to identify the first line that triggers the invalid connection error: doItAndPrint(paste(## Launching RSiteSearch, please be patient..)) I have seen this invalid connection type error when there is a sink() active that does not have a valid connection associated with it. In that case, any output generates the error. Try issuing sink() commands (without any arguments) to remove any active sinks. When there are not any more sinks you will get the message: Warning message: In sink() : no sink to remove Once you see the bad line, it may be obvious what's wrong with it, or you may need to ask for help, by putting together a minimal example that triggers it. Unfortunately, there is nothing obviously wrong with the call, nor with the environment. Omitting the line makes the function work in all my test cases. I will contact John Fox on this. If it is an invalid sink, this would just be the first call that generates output. It would be a sink somewhere before that that is setting up a bad connection (which doesn't cause problems until something is to be written). Thank you Liviu -- Brian Diggs, Ph.D. Senior Research Associate, Department of Surgery, Oregon Health Science University __ R-help@r-project.org mailing list 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.
Re: [R] debug an error that incapacitates R?
Wouldn't sink.number() give you a handle on whether the problem is that there is an invalid sink() in effect? On 15/12/2009, at 10:55 AM, Brian Diggs wrote: -Original Message- From: Liviu Andronic [mailto:landronim...@gmail.com] Sent: Sunday, December 13, 2009 4:05 AM To: Duncan Murdoch Cc: r-help@r-project.org Help Subject: Re: [R] debug an error that incapacitates R? Hello And thank you for the quick answer. On 12/13/09, Duncan Murdoch murd...@stats.uwo.ca wrote: I think you need to go back to old-fashioned debugging methods. Identify the line the triggers the error, by using debug() and single stepping through sosInit(), or by adding print() or cat() statements to it (or setting tracepoints with trace()), and seeing how many succeed before things go bad. Experimenting with browser() and subsequently with the step-through debug() I managed to identify the first line that triggers the invalid connection error: doItAndPrint(paste(## Launching RSiteSearch, please be patient..)) I have seen this invalid connection type error when there is a sink() active that does not have a valid connection associated with it. In that case, any output generates the error. Try issuing sink() commands (without any arguments) to remove any active sinks. When there are not any more sinks you will get the message: Warning message: In sink() : no sink to remove Once you see the bad line, it may be obvious what's wrong with it, or you may need to ask for help, by putting together a minimal example that triggers it. Unfortunately, there is nothing obviously wrong with the call, nor with the environment. Omitting the line makes the function work in all my test cases. I will contact John Fox on this. If it is an invalid sink, this would just be the first call that generates output. It would be a sink somewhere before that that is setting up a bad connection (which doesn't cause problems until something is to be written). Thank you Liviu -- Brian Diggs, Ph.D. Senior Research Associate, Department of Surgery, Oregon Health Science University __ R-help@r-project.org mailing list 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. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list 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.
Re: [R] debug an error that incapacitates R?
-Original Message- From: Rolf Turner [mailto:r.tur...@auckland.ac.nz] Sent: Monday, December 14, 2009 2:07 PM To: Brian Diggs Cc: r-help@r-project.org Help Subject: Re: [R] debug an error that incapacitates R? Wouldn't sink.number() give you a handle on whether the problem is that there is an invalid sink() in effect? It would. I had forgotten about that function. On 15/12/2009, at 10:55 AM, Brian Diggs wrote: -Original Message- From: Liviu Andronic [mailto:landronim...@gmail.com] Sent: Sunday, December 13, 2009 4:05 AM To: Duncan Murdoch Cc: r-help@r-project.org Help Subject: Re: [R] debug an error that incapacitates R? Hello And thank you for the quick answer. On 12/13/09, Duncan Murdoch murd...@stats.uwo.ca wrote: I think you need to go back to old-fashioned debugging methods. Identify the line the triggers the error, by using debug() and single stepping through sosInit(), or by adding print() or cat() statements to it (or setting tracepoints with trace()), and seeing how many succeed before things go bad. Experimenting with browser() and subsequently with the step-through debug() I managed to identify the first line that triggers the invalid connection error: doItAndPrint(paste(## Launching RSiteSearch, please be patient..)) I have seen this invalid connection type error when there is a sink() active that does not have a valid connection associated with it. In that case, any output generates the error. Try issuing sink() commands (without any arguments) to remove any active sinks. When there are not any more sinks you will get the message: Warning message: In sink() : no sink to remove Once you see the bad line, it may be obvious what's wrong with it, or you may need to ask for help, by putting together a minimal example that triggers it. Unfortunately, there is nothing obviously wrong with the call, nor with the environment. Omitting the line makes the function work in all my test cases. I will contact John Fox on this. If it is an invalid sink, this would just be the first call that generates output. It would be a sink somewhere before that that is setting up a bad connection (which doesn't cause problems until something is to be written). Thank you Liviu -- Brian Diggs, Ph.D. Senior Research Associate, Department of Surgery, Oregon Health Science University __ R-help@r-project.org mailing list 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. ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ## __ R-help@r-project.org mailing list 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.
[R] debug an error that incapacitates R?
Dear all How should I attempt debugging this error? sosInit() Error: invalid connection When this happens R refuses to run anything: 2+2 Error: invalid connection sessionInfo () Error in stdout() : invalid connection Debugging it seems impossible. options(error=recover) sosInit() Error: invalid connection Error during wrapup: invalid connection The error also crashes browser(). Browse[1] n debug at /home/liviu/Devel/Rcmdr-dev/Rcmdr.sos/RcmdrPlugin.sos-0.1-0/R/sosInit.R#51: doItAndPrint(paste(## Launching RSiteSearch, please be patient..)) Browse[2] Error in function () : invalid connection Error: invalid connection To reproduce the example, you would need to source the following file [1]. Then require(Rcmdr) require(sos) sosInit() and in the box enter a string similar to asdf ; HTMLgrid. If you enter simple strings such as asdf, the function will perform as expected and R will not become non-responsive. [1] http://s000.tinyupload.com/index.php?file_id=15379960405416742593 Please let me know of any ideas that would help tackle this one. Thank you Liviu This is a sessionInfo() prior to running the crash-function. sessionInfo() R version 2.10.0 (2009-10-26) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_GB.UTF-8 [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] datasets grid splines graphics stats utils grDevices [8] tcltk methods base other attached packages: [1] fortunes_1.3-6 RcmdrPlugin.HH_1.1-25HH_2.1-32 [4] leaps_2.9multcomp_1.1-2 mvtnorm_0.9-8 [7] lattice_0.17-26 RcmdrPlugin.sos_0.1-0RcmdrPlugin.Export_0.3-0 [10] Hmisc_3.7-0 survival_2.35-7 xtable_1.5-6 [13] Rcmdr_1.5-4 car_1.2-16 relimp_1.0-1 [16] sos_1.1-7brew_1.0-3 hints_1.0.1-1 loaded via a namespace (and not attached): [1] cluster_1.12.1 __ R-help@r-project.org mailing list 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.
Re: [R] debug an error that incapacitates R?
On 13/12/2009 5:31 AM, Liviu Andronic wrote: Dear all How should I attempt debugging this error? sosInit() Error: invalid connection When this happens R refuses to run anything: 2+2 Error: invalid connection sessionInfo () Error in stdout() : invalid connection Debugging it seems impossible. options(error=recover) sosInit() Error: invalid connection Error during wrapup: invalid connection The error also crashes browser(). Browse[1] n debug at /home/liviu/Devel/Rcmdr-dev/Rcmdr.sos/RcmdrPlugin.sos-0.1-0/R/sosInit.R#51: doItAndPrint(paste(## Launching RSiteSearch, please be patient..)) Browse[2] Error in function () : invalid connection Error: invalid connection To reproduce the example, you would need to source the following file [1]. Then require(Rcmdr) require(sos) sosInit() and in the box enter a string similar to asdf ; HTMLgrid. If you enter simple strings such as asdf, the function will perform as expected and R will not become non-responsive. [1] http://s000.tinyupload.com/index.php?file_id=15379960405416742593 Please let me know of any ideas that would help tackle this one. Thank you I think you need to go back to old-fashioned debugging methods. Identify the line the triggers the error, by using debug() and single stepping through sosInit(), or by adding print() or cat() statements to it (or setting tracepoints with trace()), and seeing how many succeed before things go bad. Once you see the bad line, it may be obvious what's wrong with it, or you may need to ask for help, by putting together a minimal example that triggers it. Duncan Murdoch __ R-help@r-project.org mailing list 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.
Re: [R] debug an error that incapacitates R?
Hello And thank you for the quick answer. On 12/13/09, Duncan Murdoch murd...@stats.uwo.ca wrote: I think you need to go back to old-fashioned debugging methods. Identify the line the triggers the error, by using debug() and single stepping through sosInit(), or by adding print() or cat() statements to it (or setting tracepoints with trace()), and seeing how many succeed before things go bad. Experimenting with browser() and subsequently with the step-through debug() I managed to identify the first line that triggers the invalid connection error: doItAndPrint(paste(## Launching RSiteSearch, please be patient..)) Once you see the bad line, it may be obvious what's wrong with it, or you may need to ask for help, by putting together a minimal example that triggers it. Unfortunately, there is nothing obviously wrong with the call, nor with the environment. Omitting the line makes the function work in all my test cases. I will contact John Fox on this. Thank you Liviu __ R-help@r-project.org mailing list 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.
[R] debug(sum) error
Hi, I'm working through R-debug-tools.pdf and on page 7 it describes doing: Browse[1] debug(sum) ## Flag sum for debugging however, when I try this, I get: Browse[1] debug(sum)Error in debug(fun) : argument must be a closure Does anyone know why I get this error, and how to work around it? Thanks. _ Hotmail: Powerful Free email with security by Microsoft. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug(sum) error
On 10/10/2009 7:00 PM, Another Oneforyou wrote: Hi, I'm working through R-debug-tools.pdf and on page 7 it describes doing: Browse[1] debug(sum) ## Flag sum for debugging however, when I try this, I get: Browse[1] debug(sum)Error in debug(fun) : argument must be a closure Does anyone know why I get this error, and how to work around it? debug() only works on regular functions (which are called closures). sum() is a special built in function, because it is so frequently used, and because it needs to be fast. So you can't debug it. Whoever wrote those instructions should update them to use a different example. (Google suggests that the document was written in 2002, so someone may very well have already done so.) Duncan __ R-help@r-project.org mailing list 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.
Re: [R] Debug
On Oct 1, 2009, at 11:04 AM, Tammy Ma wrote: provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list 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.
Re: [R] Debug
From: metal_lical...@live.com To: r-help@r-project.org Subject: Debug Date: Thu, 1 Oct 2009 15:21:42 +0300 Hi, R-Users,' I have written a programe to process the bunch of files in one folder. But there is a error came out; How can I know which file returns error when being processed? I have tested the first 1-10th files, no any problem. But the problems is I have more than 500 files. How can I know which file has the problem? Thanks Tammy Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] Debug
Hi Tammy, On Oct 1, 2009, at 11:04 AM, Tammy Ma wrote: Hi, R-Users,' I have written a programe to process the bunch of files in one folder. But there is a error came out; How can I know which file returns error when being processed? I have tested the first 1-10th files, no any problem. But the problems is I have more than 500 files. How can I know which file has the problem? See ?tryCatch Here's some (untested) code that should give you an idea of what to do: which.files - dir(path=/directory/with/files, full.names=TRUE) for (file.name in which.files) { result - tryCatch(process.file(file.name), error=function(err) err) if (inherits(result, 'error')) { cat(File, file.name, is hosed\n) } } This assumes you have a function called 'process.file' that does what you want. If the function throws an error, it will be caught and stored in the result variable. In this case, the file.name will be written to your workspace. Instead of just printing to your workspace, you could consider storing the bad file names in a list and post-process later. Hope that helps, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list 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.
[R] debug/mtrace problem
Hello, In the past I have used intensively the mtrace function from the debug package, but now with my actual version of R(2.8.1) , it is impossible to use it anymore. I've updated all my packages, and I don't understand how solve this problem... Here is an example code : foo-function(){cat(Test Function)} mtrace(foo) foo() # A tcl/tk windows open and close immediately Erreur dans FUN(l[[1L]], ...) : l'argument l est manquant, avec aucune valeur par défaut #argument l is missing without default value... I've tried to look in with traceback(), but it does not help me. traceback() 21: FUN(l[[1L]], ...) 20: lapply(savers, get, envir = nlocal.env) 19: mlocal(index(nchar(names(line.list)) 0)[l] - 1) 18: screen.line(lno) 17: assign(answer, { Here is some technical informations : Sys.info() sysname release versionnodename Windows Vista build 6001, Service Pack 1 XXX-HOME-VISTA machinelogin user x86 xxx xxx R.Version() $platform [1] i386-pc-mingw32 $arch [1] i386 $os [1] mingw32 $system [1] i386, mingw32 $status [1] $major [1] 2 $minor [1] 8.1 $year [1] 2008 $month [1] 12 $day [1] 22 $`svn rev` [1] 47281 $language [1] R $version.string [1] R version 2.8.1 (2008-12-22) Sincerely __ R-help@r-project.org mailing list 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.
[R] debug
Hi, All I have so many files in my directory. I got the following error. At this time, I couldn't use debug() to check error one by one because so many files getting invloved. How can I get some idea about my error?? . Skipping book_log-20060222T143612.txt Skipping book_log-20060222T162828.txt Skipping book_log-20060222T162833.txt Skipping book_log-20060222T183742.txt Skipping book_log-20060222T201442.txt Skipping book_log-20060224T153841.txt Skipping book_log-20060224T184225.txt Skipping book_log-20060224T193621.txt Skipping book_log-20060224T193957.txt Skipping book_log-20060225T110011.txt Skipping book_log-20060225T125836.txt Skipping book_log-20060225T131002.txt Processing book_log-20060225T165935.txt Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format Thanks a lot. Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.
Re: [R] debug
Tammy Ma wrote: Hi, All I have so many files in my directory. I got the following error. At this time, I couldn't use debug() to check error one by one because so many files getting invloved. How can I get some idea about my error?? The usual advice: simplify the problem until it's obvious. I don't know if you consider the skipping messages to be a problem, but if not, it sure looks as though the problem is in book_log-20060225T165935.txt so you can simplify things a lot by creating a copy of that file in a separate directory, and using debug or other techniques (e.g. options(error=recover) ) to diagnose it. Duncan Murdoch . Skipping book_log-20060222T143612.txt Skipping book_log-20060222T162828.txt Skipping book_log-20060222T162833.txt Skipping book_log-20060222T183742.txt Skipping book_log-20060222T201442.txt Skipping book_log-20060224T153841.txt Skipping book_log-20060224T184225.txt Skipping book_log-20060224T193621.txt Skipping book_log-20060224T193957.txt Skipping book_log-20060225T110011.txt Skipping book_log-20060225T125836.txt Skipping book_log-20060225T131002.txt Processing book_log-20060225T165935.txt Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format Thanks a lot. Tammy _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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. __ R-help@r-project.org mailing list 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.
[R] Debug help
Hi, I am getting the following error: argument is of length zero My code: temp - 0 for (j in 1 : 3) { for (k in 1 : 12) { temp - temp + as.double(C[k, (q - 1) * 3 + j]) * as.double(m_ret_reb[i + k - 1, j+1]) } } Why would R handle my temp variable as numeric(0)? Thanks -- View this message in context: http://www.nabble.com/Debug-help-tp21828706p21828706.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Debug help
On 2/4/2009 6:28 AM, ehxpieterse wrote: Hi, I am getting the following error: argument is of length zero My code: temp - 0 for (j in 1 : 3) { for (k in 1 : 12) { temp - temp + as.double(C[k, (q - 1) * 3 + j]) * as.double(m_ret_reb[i + k - 1, j+1]) } } Why would R handle my temp variable as numeric(0)? You need to send a reproducible example if you want an answer. It's more likely a problem with C or m_ret_reb or q, and we don't have those. Duncan Murdoch __ R-help@r-project.org mailing list 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.
Re: [R] Debug help
Thanks Duncan, I am translating code from Matlab into R and am still finding my feet in R. I first run TriskellData and the compute_strategy. In Matlab this is a function, so I would be looking to do the same in R. The bug is in compute_strategy. I would appreciate any help you can give. Thanks, Eduard -Original Message- From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: 04 February 2009 14:04 To: Eduard Pieterse (Macquarie Securities) Cc: r-help@r-project.org Subject: Re: [R] Debug help On 2/4/2009 6:28 AM, ehxpieterse wrote: Hi, I am getting the following error: argument is of length zero My code: temp - 0 for (j in 1 : 3) { for (k in 1 : 12) { temp - temp + as.double(C[k, (q - 1) * 3 + j]) * as.double(m_ret_reb[i + k - 1, j+1]) } } Why would R handle my temp variable as numeric(0)? You need to send a reproducible example if you want an answer. It's more likely a problem with C or m_ret_reb or q, and we don't have those. Duncan Murdoch If there is any advice in this email, it is general advice only and has been prepared by Macquarie Group or one of its related entities (“Macquarie”). Macquarie has made every reasonable effort to ensure the information provided is correct, but Macquarie makes no representation nor any warranty as to whether the information is accurate, complete or up to date. To the extent permitted by law, Macquarie accepts no responsibility for any errors or misstatements, negligent or otherwise. The information provided may be based on assumptions or market conditions and may change without notice. Macquarie, its associates, officers or employees may also have interests in the financial products referred to in this information by acting in various roles. They may buy or sell the financial products as principal or agent and as such may effect transactions which are not consistent with any recommendations (if any in this information). Macquarie or its associates may also receive fees or brokerage for acting in the above capacities. The information in this email is confidential. If you are not the intended recipient, you are not authorised to use the information in this email in any way. Macquarie does not guarantee the integrity of any emails or attached files. The view or opinions expressed are the author's own and may not reflect the view or opinions of Macquarie. Electronic communications carried within the Macquarie system may be monitored. __ R-help@r-project.org mailing list 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.
Re: [R] Debug command-how to use
What is 'debug' defined as? Include at least the assignment or 'str(debug)'. If you have not assigned anything to it, then 'debug' is a function in the basic set of R functions and may be giving you a message like: if (debug) 1 Error in if (debug) 1 : argument is not interpretable as logical str(debug) # here is what it is defined as function (fun) On Tue, Nov 11, 2008 at 9:50 PM, [EMAIL PROTECTED] wrote: I am getting this error could any one tell me why? if(debug) cat(rahul) Error in if (debug) cat(rahul) : argument is not interpretable as logical __ R-help@r-project.org mailing list 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list 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.
Re: [R] Debug command-how to use
Thanks a lot...I realised where I was going wrongif I declare debug = F then my problem is getting solved. -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2008 9:12 AM To: Agarwal, Rahul-A Cc: r-help@r-project.org Subject: Re: [R] Debug command-how to use What is 'debug' defined as? Include at least the assignment or 'str(debug)'. If you have not assigned anything to it, then 'debug' is a function in the basic set of R functions and may be giving you a message like: if (debug) 1 Error in if (debug) 1 : argument is not interpretable as logical str(debug) # here is what it is defined as function (fun) On Tue, Nov 11, 2008 at 9:50 PM, [EMAIL PROTECTED] wrote: I am getting this error could any one tell me why? if(debug) cat(rahul) Error in if (debug) cat(rahul) : argument is not interpretable as logical __ R-help@r-project.org mailing list 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list 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.