[Rd] extending strsplit(): supply pattern to keep, not to split by

2006-04-04 Thread Bill Dunlap
> strsplit("Ibuprofin 200mg", split=number.pattern,keep=TRUE) [[1]]: [1] "200" Is this a reasonable thing to want strsplit to do? Is this a reasonable parameterization of it? Bill Dunlap

Re: [Rd] extending strsplit(): supply pattern to keep, not to split by

2006-04-04 Thread Bill Dunlap
uot; Is this worth encapsulating in a standard R function? If so, is doing via an extra argument to strsplit() a reasonable way to do it? > strsplit(c("12;34:56,89,,12", "1.2, .4, 1., 1e3"), number.pattern, keep=T) [[1]]: [1] "12" "34" "56" &

Re: [Rd] Suggestions to speed up median() and has.na()

2006-04-10 Thread Bill Dunlap
< n; i++) > LOGICAL(ans)[i] = ISNAN(REAL(x)[i]); > break; > > and it's hard to see how that can be improved. It does suggest that a > faster anyNA() function would have to not be generic. -

Re: [Rd] Wishlist: 'quietly' argument for .onAttach() / .First.lib()

2006-04-13 Thread Bill Dunlap
gt; I did think you could make use of an option to decide whether to the print > the message or not, but I have always assumed that those who did want a > banner probably did not want it suppressed. If the .onAttach() used message() instead of cat() to display the banner message then you could

Re: [Rd] gsub + backslashes

2006-04-24 Thread Bill Dunlap
ng when fixed!=TRUE): > cat(gsub("/", "", "C:/Program Files/R"),"\n") C:\Program Files\R > cat(gsub("/", "\\", "C:/Program Files/R", fixed=T), "\n") C:\Program Files\R B

Re: [Rd] R CMD SHLIB

2006-05-17 Thread Bill Dunlap
er have SHLIB complain if it sees a -flag that SHLIB doesn't recognize. Otherwise we get portability problems. E.g., when using the Microsoft C compiler and linker a SHLIB that knows about the -l and -L flags can translate -lfoo -L/dir/subdir into LDFLAGS that link.exe knows about: foo.

Re: [Rd] Changing the generic of as.data.frame

2006-05-22 Thread Bill Dunlap
are the unique strings in the argument. This may save time and space if there a many repeated values in the strings and may make the statistical modelling functions easier to use. The default is TRUE, unless one sets options(stringsAsFactors=FALSE). ... ---

Re: [Rd] Changing the generic of as.data.frame

2006-05-22 Thread Bill Dunlap
On Mon, 22 May 2006, Prof Brian Ripley wrote: > On Mon, 22 May 2006, Bill Dunlap wrote: > > > On Mon, 22 May 2006, Prof Brian Ripley wrote: > > > >> The other motivation was to allow the option to not convert character > >> vectors to factors, wh

Re: [Rd] grep() and factors

2006-06-05 Thread Bill Dunlap
quot;character" R does this when grepping an integer vector. R> grep("1", 0:11, value=T) [1] "1" "10" "11" help(grep) says it returns "the matching elements themselves", but doesn't say if "themselves" means before or a

Re: [Rd] grep() and factors

2006-06-05 Thread Bill Dunlap
be my first inclination also. I would have expected the output of grep(pattern, text, value=TRUE) to be identical to that of text[grep(pattern, text, value=FALSE)] no matter what class text has. No end users have seen this in Splus so we can change it to anything, but we want to keep it th

Re: [Rd] download.file() yields incomplete files with method="internal"

2006-06-15 Thread Bill Dunlap
year 2006 > month 06 > day01 > svn rev38247 > language R > version.string Version 2.3.1 (2006-06-01) > > win.version() > [1] "Windows XP Professional (build 2600) Service Pack 2.0" > > > Many thanks in advance and be

Re: [Rd] Any interest in "merge" and "by" implementations specifically for sorted data?

2006-07-28 Thread Bill Dunlap
3.24 0.78 44.11 0.00 0.00 To save setup time in the S code, out-of-range values in the group argument (negatives, values greater than ngroup, and NA's), mean that the correponding element in x is ignored. Bill Dunlap

Re: [Rd] Any interest in "merge" and "by" implementations specifically for sorted data?

2006-07-28 Thread Bill Dunlap
ing (i.e. higher values will > represent larger MTB firms, etc). > > That just leaves the problem of calculating stats on short sequences > of of a longer integer. > > > They are fast: > > > >> x<-runif(2e6) > >> i<-rep(1:1e6, 2) > >> sys.time

Re: [Rd] Strict seq: a recommendation

2006-08-23 Thread Bill Dunlap
gt; Dominick Samperi wrote: > > In for loops of the form: > > for(m in seq(beg,end)) > > ... > > > > when beg > end, the default behavior is > > to decrement, and the action described > > by ... is executed at least once. ---

Re: [Rd] "+" for character method...

2006-08-25 Thread Bill Dunlap
NA 2.00 4.141593 2 NA 3.718282 7.283185 3 NA 8.389056 10.424778 Warning message: + not meaningful for factors in: Ops.factor(left, right) If we made + do paste(sep="") for character+number then we would lose the messages and let garbage flow further down the pipe. Shoul

Re: [Rd] enhancement request for labeling help windows in Windows

2006-09-06 Thread Bill Dunlap
See, e.g., http://www.helpware.net/FAR/help/dlg_hhpedit_sec.htm -------- 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 no

Re: [Rd] (PR#9202) Re: Bugs with partial name matching

2006-09-08 Thread Bill Dunlap
tfind=T' if you # want an error to occur when there is no such named element. NOT to be used for slots. function(object, name, mustfind = F) .Internal(elNamed(object, name, mustfind), "S_el_named", T, 0) It isn't used much and has some surprises. E.g., elNamed(zlis

Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Bill Dunlap
) 1, list(a=quote(foo))) function(a = foo) 1 > substitute(function(a=func(100))func(a), list(func=quote(myFunction))) function(a = myFunction(100)) myFunction(a) R's substitute does not appear to go into the 'formals' of a function definition when looking for names t

Re: [Rd] Question about substitute() and function def

2006-09-14 Thread Bill Dunlap
re substituted. In R I'm not sure what class/mode the argument name in the formals list has. The formals list is a "pairlist" and the argument names are th names of the pairlist. What internal class/mode do they have? However, substitute() in R does not appear to go into formal a

Re: [Rd] sprintf behavior (PR#9250)

2006-09-26 Thread Bill Dunlap
= 0) The warning is mostly emitted when the error is benign, but it might help get people to think about what they are typing. 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 necessaril

Re: [Rd] Warning on backslash sequences (was sprintf behavior)

2006-09-27 Thread Bill Dunlap
ide of brackets would give incorrect results. > > bayesmix/R/JAGScontrol.R: text[4] <- "-inits.R\"\n\initialize\n" > > SciViews/svDialogs/R/fixedDlg.wxPython.R:if (length(grep("[\.]", > > basename(res))) == 0) In SciViews I also see comman

Re: [Rd] Warning on backslash sequences (was sprintf behavior)

2006-09-28 Thread Bill Dunlap
t to find too many folks using \f where they intended > > either \\f or f.) > > > > We don't support unicode so we won't do anything with the \u or > > \U. That is something Splus does need to warn about to aid in > > porting stuff from R.

Re: [Rd] how to determine if a function's result is invisible

2006-10-26 Thread Bill Dunlap
eval.with.vis <- function(expr, envir = parent.frame(), enclos = if (is.list(envir) || is.pairlist(envir)) parent.frame() else baseenv()) .Internal(eval.with.vis(expr, envir, enclos)) Perhaps that could be adapted for more general use. -

Re: [Rd] man page for as.matrix for data frames outdated?

2006-11-03 Thread Bill Dunlap
quot;,"ccc"), titi=c(.9,.9,999.9)) R> as.matrix(df7) toto titi 1 "a" " 0.9" 2 "bb" " 0.9" 3 "ccc" "999.9" Once such a decision is made it is hard to change things, especially when the be

Re: [Rd] eval(match.call()) (PR#9339)

2006-11-03 Thread Bill Dunlap
It currently runs into uninitialized memory at the end of ".Primitive". (This is in a copy of R source from June 2006.) Bill Dunlap Insightful Corporation bill at insightful dot com 360-428-8146 "All statements in this message represent the opinions of th

Re: [Rd] readBin(what="character", n=overcount)->extra "" in result (PR#9361)

2006-11-13 Thread Bill Dunlap
On Mon, 13 Nov 2006 [EMAIL PROTECTED] wrote: > When I use readBin() to read an unknown number > of null-terminated strings from a file by supplying > an overcount as the n= argument, it appends an empty > string to the result. > > > tf<-tempfile() > > strings<-c("One","Two","Three") > > writeBin(s

Re: [Rd] c.factor

2006-11-14 Thread Bill Dunlap
d e f g h > >>> Levels: d e f g h > >>>> c(x,y) > >>> [1] 1 2 3 4 5 1 2 3 4 5 > >>>> > >>> > >>> Is there a case for a new method c.factor as follows? Does something > >>> similar exist already? Is there a better way to write the function? -

Re: [Rd] c.factor

2006-11-15 Thread Bill Dunlap
unction called concat.two(x,y) with is generic and has 2 arguments to make it easer to write methods for. concat(x,y,z) calls concat.two(concat.two(x,y),z). concat() is not used much, but it is the Summary group functions: min, max, sum, etc. ---

[Rd] setting up a plot without plotting any data

2006-11-17 Thread Bill Dunlap
;, sig=signature(x="missing", y="missing"), definition=function(x, y, ...).plot.noxy(...)) E.g., plot(xlim=c(-2,2), ylim=c(-2,2)) # set up plot and draw axes for(i in -10:10)points( (.8+.7i)^i) # add points to graph --

<    1   2