[Rd] grep with fixed=TRUE and ignore.case=TRUE
Dear R developers, I suggest to modify the behaviour of grep function with fixed=TRUE option. Currently, fixed=TRUE implies ignore.case=FALSE (overrides ignore.case=TRUE, if set by the user). I suggest to keep ignore.case as set by the user even if fixed=TRUE. Since the default of ignore.case is FALSE, this would not change the behaviour of grep, if the user does not set ignore.case explicitly. In my opinion, fixed=TRUE is most useful for suppressing meta-character expansion. On the other hand, for a simple word search, ignoring case is sometimes useful. If for some reason, it is better to keep the current behavior of grep, then I suggest to extend the documentation as follows: ORIGINAL: fixed: logical. If 'TRUE', 'pattern' is a string to be matched as is. Overrides all conflicting arguments. SUGGESTED: fixed: logical. If 'TRUE', 'pattern' is a string to be matched as is. Overrides all conflicting arguments including ignore.case. All the best, Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] grep with fixed=TRUE and ignore.case=TRUE
Seems like a good idea to me. Here is a workaround that works in any event which combines (?i), \Q and \E . to get the same effect. (?i) gives case insensitive matches and \Q and \E quote and endquote the intervening text disabling special characters: x - c(D.G cat, d.g cat, dog cat) z - d.g rx - paste((?i)\\Q, z, \\E, sep = ) grep(rx, x, perl = TRUE) # 1 2 On 5/7/07, Petr Savicky [EMAIL PROTECTED] wrote: Dear R developers, I suggest to modify the behaviour of grep function with fixed=TRUE option. Currently, fixed=TRUE implies ignore.case=FALSE (overrides ignore.case=TRUE, if set by the user). I suggest to keep ignore.case as set by the user even if fixed=TRUE. Since the default of ignore.case is FALSE, this would not change the behaviour of grep, if the user does not set ignore.case explicitly. In my opinion, fixed=TRUE is most useful for suppressing meta-character expansion. On the other hand, for a simple word search, ignoring case is sometimes useful. If for some reason, it is better to keep the current behavior of grep, then I suggest to extend the documentation as follows: ORIGINAL: fixed: logical. If 'TRUE', 'pattern' is a string to be matched as is. Overrides all conflicting arguments. SUGGESTED: fixed: logical. If 'TRUE', 'pattern' is a string to be matched as is. Overrides all conflicting arguments including ignore.case. All the best, Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Qt device update
On 5/5/07, Prof Brian Ripley [EMAIL PROTECTED] wrote: [...] odev.interactive() regards devices with the displaylist enabled as interactive, and packages can register the names of their devices as interactive via deviceIsInteractive(). Thanks. A related issue: 2.5.0's NEWS has: o options(device = ) now accepts a function object as well as the name of a function. (For some reason, I had thought this was true all along, but in any case) This means that it's now reasonable to do options(device = function() x11(, 4, 4)) But then I get (iff there is no device open) example(glm) Error in match(x, table, nomatch = 0) : 'match' requires vector arguments because dev.interactive() doesn't know about the change yet. dev.interactive() cannot really do anything useful in this case, but an error seems too harsh (especially since example(glm) doesn't even have any graphics). -Deepayan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD Rdconv drops sections: arguments, seealso, examples (PR#9649)
On Fri, 4 May 2007, Prof Brian Ripley wrote: On Thu, 3 May 2007, Prof Brian Ripley wrote: It is not clear to me that throwing an error is helpful as it would stop the package installation process when all but one section in one .Rd file would be useful. But it would seem good to give a warning, and so I propose that we adapt your code to do so. Doing so (now in R-devel) shows a couple of false positives (\align{{} in Paren.Rd is one), and rather a lot of correct warnings about excess }s that are not doing any harm. So I have tuned the warnings to be less strident in the latter case. That sounds good. Here is a modification of your fix that prints a message for problem in the Rd file, not just the first. E.g., in an old version of the msm package it gives Note: unmatched right brace in './msm/man/deltamethod.Rd' on or after line 32 Note: unmatched right brace in './msm/man/deltamethod.Rd' on or after line 54 Note: unmatched right brace in './msm/man/deltamethod.Rd' on or after line 55 instead of just complaining about the first one. Index: Rdconv.pm === --- Rdconv.pm (revision 41470) +++ Rdconv.pm (working copy) @@ -258,24 +258,25 @@ } # Any remaining brackets must be unmatched ones. # However, unmatched brackets are sometimes legal, -# (e.g. \alias{{}), so only warn. +# (e.g. \alias{{}), so only warn. # }match brace in comment if ($complete_text =~ /([{}])/s) { # Would like to tell which which line has unmatched { or }, # but lines starting with % have already been removed. # Hence the 'on or after' in the message. my $badlineno = 0 ; - my $extra_info = \'$1\' ; -$extra_info = \'$1\' if $complete_text =~ /(\\\w+{)/ ; foreach my $line (split /\n/, $complete_text) { $badlineno++; - last if ($line =~ /[{}]/) ; + if ($line =~ /([{}])/) { + my $extra_info = \'$1\' ; + $extra_info = \'$1\' if $line =~ /(\\\w+{)/ ; # }match brace in pattern + if( $extra_info =~ /^'}'$/ ) { + warn Note: unmatched right brace in '$Rdname'. +on or after line $badlineno\n; + } elsif(! ($extra_info =~ /\\alias{/) ) # }match brace in pattern + { warn Warning: unmatched brace ($extra_info) in '$Rdname'. + on or after line $badlineno\n; } + } } - if( $extra_info =~ /^'}'$/ ) { - warn Note: unmatched right brace in '$Rdname'. -on or after line $badlineno\n; - } elsif(! ($extra_info =~ /\\alias{/) ) - { warn Warning: unmatched brace ($extra_info) in '$Rdname'. - on or after line $badlineno\n; } } } Bill Dunlap Insightful Corporation bill at insightful dot com 360-428-8146 All statements in this message represent the opinions of the author and do not necessarily reflect Insightful Corporation policy or position. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Qt device update
On Mon, 7 May 2007, Deepayan Sarkar wrote: On 5/5/07, Prof Brian Ripley [EMAIL PROTECTED] wrote: [...] o dev.interactive() regards devices with the displaylist enabled as interactive, and packages can register the names of their devices as interactive via deviceIsInteractive(). Thanks. A related issue: 2.5.0's NEWS has: o options(device = ) now accepts a function object as well as the name of a function. (For some reason, I had thought this was true all along, but in any case) This means that it's now reasonable to do options(device = function() x11(, 4, 4)) But then I get (iff there is no device open) example(glm) Error in match(x, table, nomatch = 0) : 'match' requires vector arguments because dev.interactive() doesn't know about the change yet. dev.interactive() cannot really do anything useful in this case, but an error seems too harsh (especially since example(glm) doesn't even have any graphics). Thanks, easily fixed. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] sending signals to embedded R
On 5/6/07, Deepayan Sarkar [EMAIL PROTECTED] wrote: I will have to start learning about gdb sometime soon, but in this case, the problem seems to be due to the interaction of R_tryEval() and graphics, and has nothing to do with interruptions. Here's a variant of the trEval test case that triggers a legitimate error caused by grid.text('foo', gp = gpar(font=1, fontface=1)) [...] Running this, I get: [EMAIL PROTECTED]:~$ R-devel CMD ./tryEvalGraphics R version 2.6.0 Under development (unstable) (2007-05-04 r41439) [...] [Previously saved workspace restored] ** I **: Executing command: library(lattice) [1] stats graphics grDevices utils datasets lattice [7] rcompgen methods base ** I **: Succeeded ** I **: Executing command: library(grid) [1] grid stats graphics grDevices utils datasets [7] lattice rcompgen methods base ** I **: Succeeded ** I **: Executing command: grid.text('foo', gp = gpar(font=1, fontface=1)) Error in validGP(list(...)) : Must specify only one of 'font' and 'fontface' Error executing: grid.text('foo', gp = gpar(font=1, fontface=1)) ** I **: Succeeded ** I **: Executing command: xyplot(1 ~ 1, panel = function() grid.text('foo', gp = gpar(font=1, fontface=1))) Error in validGP(list(...)) : Must specify only one of 'font' and 'fontface' *** caught segfault *** address 0x22000440, cause 'memory not mapped' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: 3 [EMAIL PROTECTED]:~$ And running this again with optimization turned off, I get for the last command: ** I **: Executing command: xyplot(1 ~ 1, panel = function() grid.text('foo', gp = gpar(font=1, fontface=1))) Error in validGP(list(...)) : Must specify only one of 'font' and 'fontface' Error: unprotect(): only 0 protected items ** I **: Succeeded -Deepayan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Problem calling $ inside a $ method
Hello, I wonder if this will make it through the spam filters given the subject line. I'm seeing the following when trying to call a dollar method inside of a dollar method. setClass(Foo, representation(d=list)) [1] Foo f - new(Foo, d=list(bob=1, alice=2)) ## We can call dollar at this level and it works as expected `$`(f, bo) [1] 1 `$`(f, al) [1] 2 ## So set a method on Foo that does this setMethod($, Foo, function(x, name) `$`([EMAIL PROTECTED], name)) [1] $ ## But it doesn't work. Why? f$bo NULL f$al NULL ## Here is a hackish workaround. setMethod($, Foo, function(x, name) eval(substitute([EMAIL PROTECTED], list(FOO=name [1] $ f$bo [1] 1 f$al [1] 2 Other suggestions for workarounds? Is this a bug? + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] sending signals to embedded R [SOLVED]
On 5/7/07, Deepayan Sarkar [EMAIL PROTECTED] wrote: On 5/6/07, Deepayan Sarkar [EMAIL PROTECTED] wrote: I will have to start learning about gdb sometime soon, but in this case, the problem seems to be due to the interaction of R_tryEval() and graphics, and has nothing to do with interruptions. Here's a variant of the trEval test case that triggers a legitimate error caused by [...] Turns out R_tryEval is not to blame; the error (here as well as in my GUI) was occurring inside the unprotected call to PrintValue() after tryEval returned. I should have noticed that sooner. Sorry for the noise. -Deepayan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel