Re: [Rd] proposed change to 'sample'

2010-06-20 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Patrick Burns > Sent: Sunday, June 20, 2010 3:08 AM > To: r-devel@r-project.org > Subject: [Rd] proposed change to 'sample' > > There is a weakness in the 'sample' > function t

Re: [Rd] proposed change to 'sample'

2010-06-20 Thread William Dunlap
> -Original Message- > From: Peter Dalgaard [mailto:pda...@gmail.com] > Sent: Sunday, June 20, 2010 2:12 PM > To: William Dunlap > Cc: Patrick Burns; r-devel@r-project.org > Subject: Re: [Rd] proposed change to 'sample' > > William Dunlap wrote: > &g

[Rd] problem with zero-weighted observations in predict.lm?

2010-07-27 Thread William Dunlap
In modelling functions some people like to use a weight of 0 to drop an observation instead of using a subset value of FALSE. E.g., weights=c(0,1,1,...) instead of subset=c(FALSE, TRUE, TRUE, ...) to drop the first observation. lm() and summary.lm() appear to treat these in the same way, decr

Re: [Rd] transpose of complex matrices in R

2010-07-30 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Olaf Mersmann > Sent: Friday, July 30, 2010 3:01 AM > To: Robin Hankin > Cc: R-devel@r-project.org; Martin Maechler > Subject: Re: [Rd] transpose of complex matrices in R > > H

[Rd] problem in predict.lm(type="terms", terms=someNames, interval="confidence", ...)

2010-08-04 Thread William Dunlap
R's predict.lm() fails when trying to compute term-wise confidence (or prediction) intervals for a subset of the terms in a model: > dat <- data.frame(y=log(1:10), x=1:10, fac=rep(LETTERS[11:13],c(3,3,4))) > fit <- lm(y~fac*x, data=dat) > # can compute intervals for all terms > pfit <- predict(fit

Re: [Rd] rbind on data.frame that contains a column that is also a data.frame

2010-08-06 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Nicholas > L Crookston > Sent: Friday, August 06, 2010 8:35 AM > To: Michael Lachmann > Cc: r-devel-boun...@r-project.org; r-devel@r-project.org > Subject: Re: [Rd] rbind on da

[Rd] No [[<-.factor()

2010-08-25 Thread William Dunlap
Should there be a [[<-.factor() that either throws an error or acts like [<-.factor() to avoid making an illegal object of class factor? > z <- factor(c("Two","Two","Three"), levels=c("One","Two","Three")) > z [1] Two Two Three Levels: One Two Three > str(z) Factor w/ 3 levels "On

Re: [Rd] Drop single-dimensional array

2010-09-09 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Arni Magnusson > Sent: Wednesday, September 08, 2010 11:55 AM > To: r-devel@r-project.org > Cc: Simon Urbanek > Subject: [Rd] Drop single-dimensional array > > Hi Simon, thank

Re: [Rd] Problem with WARNING...headers with CRLF line endings

2010-09-13 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of cstrato > Sent: Monday, September 13, 2010 2:08 PM > To: r-devel@r-project.org > Subject: [Rd] Problem with WARNING...headers with CRLF line endings > > Dear all, > > When ru

Re: [Rd] a small suggestion for improving the building of packages

2010-09-16 Thread William Dunlap
> From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Janko Thyson > Sent: Thursday, September 16, 2010 11:19 AM > To: r-de...@r-project. org > Subject: Re: [Rd] a small suggestion for improving the > building of packages ... > Dear Uwe, > in principle, I to

Re: [Rd] scoping goes wrong when some functions are used within others.

2010-10-01 Thread William Dunlap
One of the complaints in your stackoverlow references concerned doBy::transformBy and the error message came from eval(). Using eval() means you are throwing the usual scoping rules out the window and making up some new ones. Using a non-core package means you are at the mercy of its writer. In

Re: [Rd] calling browser on error

2010-10-15 Thread William Dunlap
He said to use options(error=...) instead of tryCatch(error=...). In C++ lingo, the handler set by options("error") is called when the exception is thrown while tryCatch's handler is called when it is caught. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- >

[Rd] wishlist: system.file(..., mustExist = TRUE)

2010-10-18 Thread William Dunlap
I find system.file() handy for writing examples, but if the user mistypes its arguments or if a package is not up to date its return value of "" can lead to trouble. This forces the example to be wordier than I'd like. E.g., the following example works > scan(what="", sep="\n", system.file("DES

Re: [Rd] new.env does not recognize parents from subclassesof "environment"

2010-10-21 Thread William Dunlap
The traceback looks very similar to a problem in R 2.11.1 reported earlier this month by Troy Robertson. > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Troy Robertson > Sent: Wednesday, October 06, 2010 6:13 PM > To: 'r-devel@R-project.org' >

Re: [Rd] must .Call C functions return SEXP?

2010-10-28 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Andrew Piskorski > Sent: Thursday, October 28, 2010 6:48 AM > To: Simon Urbanek > Cc: r-devel@r-project.org > Subject: Re: [Rd] must .Call C functions return SEXP? > > On Thu,

Re: [Rd] RFC: sapply() limitation from vector to matrix, but not further

2010-12-01 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Hadley Wickham > Sent: Wednesday, December 01, 2010 6:27 AM > To: Martin Maechler > Cc: r-de...@stat.math.ethz.ch > Subject: Re: [Rd] RFC: sapply() limitation from vector to >

[Rd] when to use pairlist instead list

2010-12-06 Thread William Dunlap
I was writing some assertion tests for modelling-related code I had written and was surprised to see one test fail because the "specials" attribute of the output of terms() is a "pairlist" instead of a "list". In 2.12.0 I get: > dput(attr(terms(y~Spec(x1)+x2, specials=c("Spec")), "specials"))

Re: [Rd] Surprising behavior of letters[c(NA, NA)]

2010-12-18 Thread William Dunlap
I'm agnostic at this point about the recycling rules for logical subscripting, but I've been coming around to thinking that x[logicalSubscript] should only return the values of x such that the corresponding value of logicalSubscript is TRUE. Values in logicalSubscript of NA and FALSE should be tre

[Rd] formula(model.frame(y~.^2, data=d)) does not return formula from terms attribute of the model.frame

2011-01-06 Thread William Dunlap
In R 2.12.0 I get > d <- data.frame(x=1:10, y=log(1:10), f3=LETTERS[rep(1:3,c(3,3,4))]) > m <- model.frame(y~.^2, data=d) > formula(m) y ~ x + f3 In S+ formula(m) gives formula given to model.frame(), but in R you have to do the following get that formula: > formula(attr(m, "terms")) y

[Rd] why is class externalptr considered recursive?

2011-01-13 Thread William Dunlap
I have a function to search through R code and look for certain language constructs. It uses the idiom if (is.recursive(object)) { object <- as.list(object) for(element in object) { Recall(element) # recurse further into object } } and I was surprised tha

[Rd] buglet in weighted.residuals(mlmObject)

2011-01-19 Thread William Dunlap
When weighted.residuals() is given a fitted model object with several responses (class mlm) and some zero weights it returns a vector instead of a matrix. It looks like it is doing resids[ weights != 0 ] instead of resids[ weights != 0, , drop=FALSE] in the multi-response case. E.g., > d4

Re: [Rd] formula(model.frame(y~.^2, data=d)) does not return formula from terms attribute of the model.frame

2011-01-19 Thread William Dunlap
p tibco.com > -Original Message- > From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] > Sent: Wednesday, January 19, 2011 6:50 AM > To: William Dunlap > Cc: r-devel@r-project.org > Subject: Re: [Rd] formula(model.frame(y~.^2, data=d)) does > not return formula fro

[Rd] as.list(subclassed function) -> cannot coerce type 'closure' to vector of type 'list'

2011-02-07 Thread William Dunlap
I was looking for all the glm-related 'family' functions in stats using the following predicate that returns TRUE for any function whose first argument is called "link". is.family <- function(object) is.function(object) && identical(names(as.list(object))[1], "link") It threw an err

Re: [Rd] matrixStats: Extend to arrays too (Was: Re: Suggestion: Adding quick rowMin and rowMax functions to base package)

2011-02-16 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Hadley Wickham > Sent: Wednesday, February 16, 2011 7:32 AM > To: Tim Hesterberg > Cc: Henrik Bengtsson; r-devel@r-project.org > Subject: Re: [Rd] matrixStats: Extend to arrays

Re: [Rd] matrixStats: Extend to arrays too (Was: Re: Suggestion: Adding quick rowMin and rowMax functions to base package)

2011-02-16 Thread William Dunlap
> -Original Message- > From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On > Behalf Of Hadley Wickham > Sent: Wednesday, February 16, 2011 9:21 AM > To: William Dunlap > Cc: Tim Hesterberg; Henrik Bengtsson; r-devel@r-project.org > Subject: Re: [Rd] matrixSt

Re: [Rd] Anomaly in [.terms

2011-02-22 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Terry Therneau > Sent: Monday, February 21, 2011 11:32 AM > To: r-devel@r-project.org > Subject: [Rd] Anomaly in [.terms > > > This arose when working on an addition to coxp

Re: [Rd] discrepancy between lm and MASS:rlm

2011-03-14 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Vadim Ogranovich > Sent: Monday, March 14, 2011 10:37 AM > To: 'r-devel@r-project.org' > Subject: [Rd] discrepancy between lm and MASS:rlm > > Dear R-devel, > > There seems t

[Rd] split(factor, shortGroupVector) gives incorrect results in R 2.12.2

2011-03-21 Thread William Dunlap
When split's x argument has a class attribute and the grouping vector, f, is shorter than x then split gives the wrong result. It appears to not extend f to the length of x before doing the split. E.g., > split(factor(letters[1:3]), "Group one") # expect all 3 elements in the single group $

[Rd] two minor bugs in rowsum()

2011-03-25 Thread William Dunlap
(a) In R 2.12.2 rowsum can overflow if given an integer input: > rowsum(c(2e9L, 2e9L), c("a", "a")) [,1] a -294967296 > 2^32 + .Last.value [,1] a 4e+09 Should it be changed to coerce its x argument to numeric (double precision) so it always returns a numeric output? (b) When

Re: [Rd] Reading 64-bit integers

2011-03-29 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Jon Clayden > Sent: Tuesday, March 29, 2011 5:46 AM > To: r-devel@r-project.org > Subject: [Rd] Reading 64-bit integers > > Dear all, > > I see from some previous threads tha

Re: [Rd] Reading 64-bit integers

2011-03-30 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Simon Urbanek > Sent: Tuesday, March 29, 2011 6:49 PM > To: Duncan Murdoch > Cc: r-devel@r-project.org > Subject: Re: [Rd] Reading 64-bit integers > > > On Mar 29, 2011, at 8

[Rd] [[.data.frame oddity

2011-04-04 Thread William Dunlap
data.frame[[row,col]] unclasses its output. Is that proper? > d <- data.frame(num=1:4, fac=factor(letters[11:14],levels=letters[1:15]), date=as.Date("2011-04-01") + (0:3), lt=as.POSIXlt("2011-04-01") + (0:3)*1e5, pv=package_version(c("1.2-3", "4.5","6.7", "

Re: [Rd] duplicates() function

2011-04-08 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Duncan Murdoch > Sent: Friday, April 08, 2011 8:16 AM > To: Joshua Ulrich > Cc: R-devel@r-project.org > Subject: Re: [Rd] duplicates() function > > On 08/04/2011 11:08 AM, Josh

[Rd] sort.int(S3object) strips class but not the is.object flag

2011-04-11 Thread William Dunlap
If x has an S3 class then sort.int(x) returns a value without an S3 class but which has the is.object flag set, which, I think, causes identical() give a false/misleading report: > x <- structure(1:3, class="unrecognizedClass") > y <- sort.int(x) > t <- 1:3 > identical(y, t) # expect TRUE

Re: [Rd] sort.int(S3object) strips class but not the is.object flag

2011-04-11 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of William Dunlap > Sent: Monday, April 11, 2011 10:10 AM > To: R-devel@r-project.org > Subject: [Rd] sort.int(S3object) strips class but not the > is.obje

[Rd] all.equal(data.frame(package_version()), ...) infinite recursion

2011-04-12 Thread William Dunlap
With R-2.12.2 on Linux: > z <- data.frame(Version=package_version(c("0.1")), row.names=c("pkgA")) > all.equal(z, z) # expect TRUE Error: evaluation nested too deeply: infinite recursion / options(expressions=)? > traceback() ... lots of lines in a 3-cycle ... 6: all.equal.list(target,

Re: [Rd] Make as.factor an S3 generic?

2011-04-20 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Martin Morgan > Sent: Wednesday, April 20, 2011 9:56 AM > To: R-devel@r-project.org > Subject: [Rd] Make as.factor an S3 generic? > > as.factor / as.ordered is not written as a

Re: [Rd] median and data frames

2011-04-29 Thread William Dunlap
> From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Martin Maechler > Sent: Friday, April 29, 2011 7:25 AM > To: Paul Johnson > Cc: r-devel > Subject: Re: [Rd] median and data frames > [ ... lots of lines elided ... ] > My vote is for deprecating mean.data

[Rd] raw connections: reading does not alter current position pointer

2011-05-02 Thread William Dunlap
Am I misunderstanding rawConnections here or are rawConnections not working right yet? It looks like I can use seek() to position the read pointer but readBin does not position the read pointer past what has just been read. > myRawTen <- as.raw(101:110) > str(myRawTen) raw [1:10] 65 66 67

Re: [Rd] External special functions (SPECIALSXP)

2011-05-25 Thread William Dunlap
> f <- function(...) { + dotArgList <- substitute(list(...)) + dotArgList + } > f(cat("foo\n"), stop("Oops"), warning("Hmm")) list(cat("foo\n"), stop("Oops"), warning("Hmm")) > # i.e., no argument was evaluated Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Messa

Re: [Rd] External special functions (SPECIALSXP)

2011-05-25 Thread William Dunlap
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: William Dunlap > Sent: Wednesday, May 25, 2011 11:20 AM > To: 'Peter Danenberg' > Cc: r-devel@r-project.org > Subject: RE: [Rd] External special functions (SPEC

Re: [Rd] possibly invalid assertion in setRefClass?

2011-06-01 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Michael Lawrence > Sent: Wednesday, June 01, 2011 9:15 AM > To: r-devel@r-project.org > Subject: [Rd] possibly invalid assertion in setRefClass? > > > setRefClass("Foo", fields

Re: [Rd] How to add a welcome message in Package development?

2011-06-10 Thread William Dunlap
I agree with Simon that package startup messages are often annoying and not often helpful. However, I think they should be generated with packageStartupMessage("your message") instead of cat("your message\n") The former may be suppressed by wrapping the call to library() with suppressPackage

[Rd] filter(x, method="recursive") when there are NA's in x messes up

2011-07-18 Thread William Dunlap
If x contains an NA then filter(x, f, method="recursive") puts NA's and 0.0's in the output in an odd pattern. It puts NA's in the length(f) positions ending at the position of the input NA and it puts a run of length(f) 0.0's starting at the position immediately after the input NA. The values aft

Re: [Rd] Randomness not due to seed

2011-07-19 Thread William Dunlap
Did you actually see some rounding differences? The lm objects made in the calls to maklm will differ in the environments attached to the formula (because you made the formula in the function). If I change both copies of that .Environment attribute to .GlobalEnv (or any other environment), then i

Re: [Rd] Out-of-date manual or small bug in R CMD check?

2011-08-30 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On > Behalf Of Duncan Murdoch > Sent: Monday, August 29, 2011 5:30 PM > To: Gabriel Becker > Cc: r-devel@r-project.org > Subject: Re: [Rd] Out-of-date manual or small bug in R CMD check? > >

[Rd] "\088" is legal syntax?

2011-09-01 Thread William Dunlap
Is it intentional that the digit 8 is allowed in octal escape sequences in character literals? > "\110" == "\088" [1] TRUE > "\8" == "\b" [1] TRUE 9's are rejected, so I'd expected 8's to be illegal as well. > "\9" Error: '\9' is an unrecognized escape in character string starting "\

[Rd] parser does not catch strings without closing quote

2011-09-01 Thread William Dunlap
Shouldn't the parser complain about unfinished strings in files? It doesn't and will tack on a newline if there isn't one there. > withOption <- function(optionList, expr) { + oldOption <- options(optionList) + on.exit(options(oldOption)) + expr + } > cat(file=tf<-tempfil

Re: [Rd] "\088" is legal syntax?

2011-09-01 Thread William Dunlap
Software wdunlap tibco.com > -Original Message- > From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Sent: Thursday, September 01, 2011 5:30 PM > To: William Dunlap > Cc: r-devel@r-project.org > Subject: Re: [Rd] "\088" is legal syntax? > > On 11-09-

Re: [Rd] "\088" is legal syntax?

2011-09-01 Thread William Dunlap
uot;, ./relax/R/weaveR.R: input<-chartr("\283\244\283\266\283\274\283\204\283\226\283\234", ./relax/R/weaveR.R:# pc<-eval(parse(text='"\\283"')) # UTF-8-pre-char ./relax/R/weaveR.R: '"\\283\\244\\283\\266\\283\\274\\283\\204\\283\\226

Re: [Rd] parser does not catch strings without closing quote

2011-09-02 Thread William Dunlap
longitude", "latitude", "magnitude", "time", "depth", "trans.time") ") Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Sent: Friday,

[Rd] nobs(lm(...)) != nobs(glm(...)) when there are 0s in weights

2011-09-08 Thread William Dunlap
What is the rationale for nobs.lm omitting observations with zero weights while nobs.glm includes them? > df <- data.frame(x1=log(1:10), x2=1/(1:10), y=1:10, > wt=c(0,2,0,4,0,6,7,8,9,10)) > nobs(lm(data=df, y~x1+x2, weights=wt)) [1] 7 > nobs(glm(data=df, y~x1+x2, weights=wt)) [1] 10 The anova me

[Rd] should dir(all=TRUE) return "." and ".."?

2011-09-23 Thread William Dunlap
dir(all=TRUE) returns the file names "." and ".." while dir(recursive=TRUE, all=TRUE, include.dirs=TRUE) does not. I always filter out the "." and ".." entries and was wondering if anyone would mind if dir(all=TRUE) just omitted them? It might make recursive file operations like cleaning out a di

Re: [Rd] number of copies

2011-10-03 Thread William Dunlap
> -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On > Behalf Of Terry Therneau > Sent: Monday, October 03, 2011 11:44 AM > To: Simon Urbanek > Cc: r-devel@r-project.org > Subject: Re: [Rd] number of copies > > > On Mon, 2011-10-03 at 12:31

Re: [Rd] Add-on argument in sample()

2015-06-17 Thread William Dunlap
I don't like the idea of having a length-1 dim attribute trigger some behavior of sample. (Should a length-2 dim cause it to sample rows of a matrix, as unique() and duplicated() do?). S+'s sample() had another argument, 'n', that could be used to specify the size of the population to sample from

Re: [Rd] Improving string concatenation

2015-06-17 Thread William Dunlap
> ... adding the ability to concat > strings with '+' would be a relatively simple addition (no pun intended) to > the code base I believe. With a lot of other languages supporting this kind > of concatenation, this is what surprised me most when first learning R. Wow! R has a lot of surprising f

Re: [Rd] Improving string concatenation

2015-06-17 Thread William Dunlap
"+" uses > sprintf("%s is %d", c("One","Two"), numeric(0)) character(0) > sprintf("%s is %d", c("One","Two"), 17) [1] "One is 17" "Two is 17" > sprintf("%s is %d", c("One"

Re: [Rd] bquote/evalq behavior changed in R-3.2.1

2015-07-15 Thread William Dunlap
I am curious why you used evalq instead of eval in this code. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer wrote: > Hello, > > I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked > as I intended previously. Briefly, I am using

Re: [Rd] bquote/evalq behavior changed in R-3.2.1

2015-07-15 Thread William Dunlap
> the error I gave when run on 3.2.1. > > To give credit, I received the idea for using evalq from SO: > http://stackoverflow.com/a/22559385 > > Dayne > > > On Wed, Jul 15, 2015 at 3:29 PM, William Dunlap wrote: > >> I am curious why you used evalq instead of

Re: [Rd] bquote/evalq behavior changed in R-3.2.1

2015-07-15 Thread William Dunlap
2015-03-09) vs. R version 3.2.0 (2015-04-16)` [1] "3 string mismatches" I prefer the new semantics, but it is a change. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 15, 2015 at 1:25 PM, David Winsemius wrote: > > On Jul 15, 2015, at 12:51 PM, William Dunlap wrote: >

Re: [Rd] bquote/evalq behavior changed in R-3.2.1

2015-07-15 Thread William Dunlap
gt; the output or result). Using the above code still results in the x object >> not being stored in fenv on 3.1.2. >> >> Dayne >> >> On Wed, Jul 15, 2015 at 4:40 PM, William Dunlap >> wrote: >> >>> Another aspect of the change is (

Re: [Rd] Weird issue when iterating through dates

2015-08-06 Thread William Dunlap
>> Just a quick question: what's the difference between `[.Date` and `[[.Date`? >> Is it supposed to be the method for accessing the value right? > >For Dates and atomic vectors in general they are the same, but ... Even for atomic vectors with names they are not quite the same > c(One=1, Two

[Rd] unset() function?

2015-08-21 Thread William Dunlap
Does R have a function like the S/S++ unset() function? unset(name) would remove 'name' from the current evaluation frame and return its value. It allowed you to safely avoid some memory copying when calling .C or .Call. E.g., suppose you had C code like #include #include SEXP add1(SEXP p

Re: [Rd] unset() function?

2015-08-21 Thread William Dunlap
> Does R have a function like the S/S++ unset() function? That should be 'S+' or 'S-Plus', not the typo 'S++'. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Aug 21, 2015 at 1:43 PM, William Dunlap wrote: > Does R have a function like the S/S++ u

Re: [Rd] match()/%in% with language objects?

2015-08-25 Thread William Dunlap
match(x,table) and x%in%table work when x and table are lists of language objects or expressions. E.g., expression(quote(1+2), quote(log2(16))) %in% expression(3, quote(1+2), c(4L,5L,6L,7L)) #[1] TRUE FALSE list(quote(1+2), quote(log2(16))) %in% list(3, quote(1+2), c(4L,5L,6L,7L)) #[1]

Re: [Rd] match()/%in% with language objects?

2015-08-26 Thread William Dunlap
dy seems to do the right thing in that case: duplicated(x) #[1] FALSE FALSE duplicated(x[c(1,2,1)]) #[1] FALSE FALSE TRUE Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Aug 26, 2015 at 1:54 AM, Martin Maechler wrote: > >>>>> William Dunlap > >>>>&g

Re: [Rd] Proposed change in file.exists() to tolerate Windows

2015-08-27 Thread William Dunlap
## delete trailing slashes dts <- function(name) gsub("/$", "", name) if(!file.exists(dts(any_name))) { ... I don't think you want to delete the slash in "C:/" on Windows, as "C:" is not a file and "C:/" is. normalizePath() does odd things with "C:" as well. Bill Dunlap TIBCO Software

Re: [Rd] Error generated by .Internal(nchar) disappears when debugging

2015-10-05 Thread William Dunlap
I can reproduce the problem by running R-3.2.0 (on Windows), installing copula from CRAN, and then using it: > install.packages("copula") Installing package into 'C:/Program Files/R/R-3.2.0/site-library' (as 'lib' is unspecified) also installing the dependencies 'gsl', 'ADGofTest', 'pspline' Warn

[Rd] read.table reads "i" as NA_complex_

2015-10-07 Thread William Dunlap
I just noticed that read.table() and type.convert() interpret the string "i" as a missing value of type complex. > str(read.table(text=c("i\ni\ni\ni\n"))) 'data.frame': 4 obs. of 1 variable: $ V1: cplx NA NA NA ... > str(type.convert("i")) cplx NA If there are other strings in

Re: [Rd] read.table reads "i" as NA_complex_

2015-10-07 Thread William Dunlap
3, if you care. > > (Funny how an obscure issue goes unnoticed for a decade, then pops up > twice independently within a few months. A property of the Poisson process, > I suppose.) > > > > On 07 Oct 2015, at 22:22 , William Dunlap wrote: > > > > I just noticed tha

Re: [Rd] identical(..., ignore.environment=TRUE)

2015-10-13 Thread William Dunlap
MM> but I don't think we'd want to MM> change all.equal.language() at this point in time Although it would be nice if all.equal looked at least at attributes of formulas so we did not get results like > form <- y ~ x1 %in% x2 > all.equal(form, terms(form)) [1] TRUE > all.equal(terms(y~x1

[Rd] corrupt PACKAGES.gz?

2015-11-06 Thread William Dunlap
Is it just me, or did a corrupt PACKAGES.gz file get installed in the bin/windows/contrib/3.2 directory of CRAN mirrors recently? gzfile() complains about it and Cygwin's gzip cannot decompress it. I tried the following repos <- "https://cran.rstudio.com"; v <- "3.2" pkgs.gz <- paste(sep="/", re

Re: [Rd] corrupt PACKAGES.gz?

2015-11-10 Thread William Dunlap
Bill Dunlap TIBCO Software wdunlap tibco.com On Sat, Nov 7, 2015 at 12:24 AM, Uwe Ligges wrote: > Bill, > > thanks for reporting, this is currently true for all PACKAGES.gz files my > autobuilder is creating, will investigate. > > Best, > Uwe > > > > On 06.11.201

[Rd] R_MakeExternalPtr 'tag' argument

2015-11-13 Thread William Dunlap
Most packages that use the R_MakeExternalPtr function use Rf_install("pkgSpecificString") for its 'tag' argument (if they don't use R_NilValue). A few use Rf_mkChar("pkgSpecificString"). Is there any reason to prefer one over the other? Bill Dunlap TIBCO Software wdunlap tibco.com _

Re: [Rd] capturing warnings using capture.output

2015-11-23 Thread William Dunlap
When options("warn") is 0, the default, the warning is not printed until capture.output is done. Use warn=1 to capture the warnings as messages: > options(warn=0) > txt0 <- capture.output({message("A message"); warning("A warning")}, > type="message") Warning message: In eval(expr, envir, enclos

Re: [Rd] Inconsistency in treating NaN-results?

2015-11-30 Thread William Dunlap
As a side note, Splus makes sin(x) NA, with a warning, for abs(x)>1.6*2^48 (about 4.51e+14) because more than half the digits are incorrect in sin(x) for such x. E.g., in R we get: > options(digits=16) > library(Rmpfr) > sin(4.6e14) [1] -0.792253849684354 > sin(mpfr(4.6e14, precBits=500)) 1 'mpfr

Re: [Rd] [Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread William Dunlap
This would be easier if base::set.seed() accepted a value of .Random.seed instead of just a scalar integer or, new to R-3.0.0, NULL. If set.seed() returned the previous value of .Random.seed (NULL if there was no previous value) things might be even easier. People should not have to know where .

Re: [Rd] load/unload segfault puzzle

2013-06-13 Thread William Dunlap
You can also read the process map table in /proc//maps to see which shared object is associated with the illegal address that valgrind identified. Read the map table after each load or unload of a *.so with map <- readProcessMaps() and use something like subset(map, startAddr <= badAddr & bad

Re: [Rd] Calling an array in a struct in C to R

2013-06-19 Thread William Dunlap
> should I rewrite my C code using Call in R? Yes, rewrite it to use the .Call() interface. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On > Behalf > Of Tee-Jay-Ardie > Sent: We

[Rd] F statistic in add1.lm vs add1.glm

2013-06-25 Thread William Dunlap
Should the F statistic be the same when using add1() on models created by lm and glm(family=gaussian)? They are in the single-degree-of-freedom case but not in the multiple-degree-of-freedom case. MASS:addterm shows the same discrepancy. It looks like the deviance (==residual sum of squares) ge

Re: [Rd] Ctrl+C in R will terminate the child process which is spawned by using "pipe"

2013-07-02 Thread William Dunlap
If you are on a Unix-like machine try using the setsid command to run your command in a 'session' of its own. E.g., > z <- pipe("setsid /usr/bin/yes", open="r") > length(readLines(z, n=1e6)) [1] 100 > # hit control-C > length(readLines(z, n=1e6)) [1] 100 > length(readLines(z

Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread William Dunlap
> Is there any reason right-assign with "->" still exists? How much > code on CRAN uses it, and how trivially could it be excised? I use '->' a lot when doing interactive work. I often first run a command to see its printed output then decide that I had better save its value. The up-arrow key gi

Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread William Dunlap
ssage- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Friday, July 05, 2013 11:25 AM > To: William Dunlap > Cc: Barry Rowlingson; R-devel > Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()? > > > On Jul 5, 2013, at 18:59 , William Dun

Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()?

2013-07-05 Thread William Dunlap
com] > Sent: Friday, July 05, 2013 12:11 PM > To: William Dunlap > Cc: peter dalgaard; R-devel; Barry Rowlingson > Subject: Re: [Rd] should the text for RIGHT_ASSIGN be -> in getParseData()? > > Here are two more standard emacs bindings that work: Ctrl-K to cut and > Ctrl

Re: [Rd] cbind error with check.names

2013-07-24 Thread William Dunlap
> I meant what is the design principle behind check.names being hardcoded to > FALSE. > I see no conflict with the purpose of cbind from the ability to specify > check.names > at the level of cbind. One rationale is that data.frame(check.names=TRUE,...) does two things: it makes sure there are n

Re: [Rd] Extending suggestion for stopifnot

2013-08-20 Thread William Dunlap
> my own programming variant looks even nicer, >is.matrix(m) %or% "m is not a matrix but a {{class(m)}}" But it does not act nicely. All %anything% constructs have the same precedence, that of %*%. Hence x==3 %or% "x is not three" is parsed as x == ( 3 %or% "x is not three" ) which is

[Rd] how to prevent default argument values from being found

2013-10-14 Thread William Dunlap
Here is a problem I ran across in RStudio, which uses masks a number of standard R functions with versions that do a bit more than the original does. The RStudio people have figured out a way to prevent default values of arguments from being found when an argument is missing from a call! junk1

Re: [Rd] WISHLIST: on.exit(..., add=TRUE, where="first") to address common use cases

2013-11-03 Thread William Dunlap
I used to worry about the order of evaluation of on.exit expressions and thought that maybe we needed named on.exit expression so you could remove particular on.exit expressions. However, now I think I can almost always avoid such considerations and make code clearer by making a new function cal

[Rd] R interface to C API Rf_logspace_{add,sub}?

2013-11-07 Thread William Dunlap
Is there an R-language interface to the R API C-language functions Rf_logspace_add() and Rf_logspace_sub()? I don't see one but I may not looking under the right name. Various packages have functions which do that same sort of thing (log(exp(x)+exp(y)) and log(exp(x)-exp(y)) without unnecessary

Re: [Rd] Milestone: 5000 packages on CRAN

2013-11-08 Thread William Dunlap
> "Currently, the CRAN package repository features 5001 available packages." > > Going from 4000 to 5000 packages took 14.5 months - that's one new package > every 10.5 hours. Behind every package there are real people. These > user-contributed packages are maintained by ~2900 people [2] - that's

Re: [Rd] Parallel computing: how to transmit multiple parameters to a function in parLapply?

2013-12-24 Thread William Dunlap
You can put the function of interest and any global variables it needs into a private environment, which gets sent along with the function to the child processes. E.g. library(parallel) cl3 <- makeCluster(3) y <- c(1,100,1) addY <- function(x) x + y withGlobals <- function(FUN, ...){ envi

Re: [Rd] Parallel computing: how to transmit multiple parameters to a function in parLapply?

2013-12-27 Thread William Dunlap
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Yu Wan [mailto:walter...@126.com] Sent: Friday, December 27, 2013 3:46 AM To: William Dunlap; alex...@4dscape.com Cc: r-devel@r-project.org Subject: Re: [Rd] Parallel computing: how to transmit multiple parameters to a function in parL

Re: [Rd] file.exists does not like path names ending in /

2014-01-17 Thread William Dunlap
> I think that ignoring a terminal slash/backslash on Windows would do no > harm: Windows makes a distinction between "C:" and "C:/": the former is not a file (or directory) and the latter is. Bill Dunlap TIBCO Software wdunlap tibco.com > -Original Message- > From: r-devel-boun...@r-pr

Re: [Rd] package NAMESPACE question

2014-01-28 Thread William Dunlap
You can more or less get what you want by reassigning the environment of the formula to be a child of its original environment, where you put your private functions in the new environment. For example, do not export trt and make the following change to your R code: % diff -u foo/R/cmt.R~ foo/R

Re: [Rd] package NAMESPACE question

2014-01-28 Thread William Dunlap
[inline below] Bill Dunlap TIBCO Software wdunlap tibco.com > -Original Message- > From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Sent: Tuesday, January 28, 2014 10:45 AM > To: William Dunlap; Axel Urbiz; Henrik Bengtsson > Cc: r-devel > Subject: Re: [Rd]

Re: [Rd] 2 versions of same library loaded

2014-03-13 Thread William Dunlap
Have you tried using the environment variable LD_DEBUG to see what the dynamic linker is doing? E.g., env LD_DEBUG=files R or % setenv RHOME `R RHOME` % R CMD env LD_DEBUG=files $RHOME/bin/exec/R 2322: 2322: file=libR.so [0]; needed by /opt/sw/R/R-3.0.2.atlas1/lib/R/bin/ex

Re: [Rd] [RFC] A case for freezing CRAN

2014-03-20 Thread William Dunlap
> In particular, updating a package with many reverse dependencies is a > frustrating process, for everybody. As a maintainer with ~150 reverse > dependencies, I think not twice, but ten times if I really want to publish > a new version on CRAN. It might be easier if more of those packages came wi

Re: [Rd] Can the output of Sys.getenv() be improved?

2014-04-18 Thread William Dunlap
> Within an R session, type Sys.getenv() will list all the environment > variables, but each one > of them occupies about a page, so scrolling to find one is difficult. Is this > because I don't > know how to use it or something could be improved? Attaching the class "simple.list" to the output

Re: [Rd] Can the output of Sys.getenv() be improved?

2014-04-21 Thread William Dunlap
s looks bad. A print method like p <- function(x, ...) { cat(formatDL(x), sep="\n") invisible(x) } would look better. Bill Dunlap TIBCO Software wdunlap tibco.com > -Original Message- > From: Martin Maechler [mailto:maech...@stat.math.ethz.ch] > Sent: Sa

Re: [Rd] How to test if an object/argument is "parse tree" - without evaluating it?

2014-05-01 Thread William Dunlap
> This may have been asked before, but is there an elegant way to check > whether an variable/argument passed to a function is a "parse tree" > for an (unevaluated) expression or not, *without* evaluating it if > not? I doubt it. Some packages say that if the argument is a formula then its right

  1   2   3   4   5   >