[Rd] R mailing list archive: alternative interface

2005-06-26 Thread hadley wickham
For a programming competition (http://railsday.com) I recently entered, I created a web-application to nicely display mail archives. I've loaded up a couple of months worth of r-devel mail and made it available here: http://listomagic.had.co.nz/ The big advantages over the currrent mailman archiv

[Rd] Package tests: best practices

2005-08-22 Thread hadley wickham
I'm writing some tests for a package and I have a few questions regarding best practices. I've read "tests subdirectory" paragraph in writing R extension, but I'm left wanting more. Firstly, can I assume that the document root will always be set to the test directory? (that what a couple of quick

[Rd] Functions with the same name: best practices

2005-08-22 Thread hadley wickham
Ok, here's another best practices question - let's say I'm writing a package and I want to use a function name that is already claimed by a function in the base R packages. For the sake of argument, let's pretend this function is for profiling the performance of a function (like Rprof for example)

Re: [Rd] Functions with the same name: best practices

2005-08-26 Thread hadley wickham
Thanks to all of you for your advice. I will read up on namespaces and start using them to "protect" my internal function from name clashes with other packages, and endeavour to my public functions unique names. I know other languages (eg. python) separate loading a package and including it in the

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread hadley wickham
I'm not entirely sure what you want, but maybe this does the trick? data.frame.by <- function(data, variables, fun, ...) { if (length(variables) == 0 ) { df <- data.frame(results = 0) df$results <- list(fun(data$value, ...)) return(df)

Re: [Rd] Problems with example(Grid) in grid package

2005-10-21 Thread hadley wickham
I've also noticed the behaviour of grid.rect() has changed in 2.2.0. Before the fill defaulted to transparent, but now it defaults to white. Hadley On 10/21/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > The following: > > library(grid) > grid.newpage() > example(Grid) > > has the yaxis lab

Re: [Rd] Strange behaviour of type conversion (PR#8256)

2005-10-27 Thread hadley wickham
> Where is my error?? You are assuming that numbers are represented exactly: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f > 0.3/0.1 == 3 [1] FALSE Hadley __ R-devel@r-project.org mailing list https:

Re: [Rd] Brainstorm: Alpha and Beta testing of R versions

2005-11-07 Thread hadley wickham
> actually, it might not be a bad idea to require a unique > bug-entry interface -- actually we have been thinking of moving > to bugzilla -- if only Peter Dalgaard could find a smart enough > person (even to be paid) who'd port all the old bug reports into the > new format.. If you haven't alread

Re: [Rd] R-bugs e-mail {was ... (Debian Bug 344248): ...}

2005-12-21 Thread hadley wickham
> PLEASE, PLEASE: > do use > [EMAIL PROTECTED] > and nothing else Perhaps http://bugs.r-project.org/cgi-bin/R should be updated then? Hadley __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] cairo anyone?

2005-12-23 Thread hadley wickham
> | Michael Lawrence has as part of RGtk2. > > Speaking of which -- I tried to find his code anywhere on the "Internets" > following his very nice DSC presentation, but no beans. Why is this in > hiding? Is it expected to surface at some point? Any insights, Duncan? Michael is currently working

[Rd] Retrieving an unevaluated argument

2006-02-01 Thread hadley wickham
I'm trying to retrieve an unevalated argument (a list in particular). I can do this easily when I call the function directly: a1 <- function(x) match.call()$x > a1(list(y=x^2)) list(y = x^2) But when the function is called by another function, it gets trickier b <- function(x, f) f(x) > b(lis

[Rd] Converting an unevaluted list to list of unevaluted elements

2006-02-01 Thread hadley wickham
Thanks to Andy Liaw, I have realised my problem isn't getting an unevaluated argument, my problem really is converting an unevaluted list to list of unevaluted elements. That is, how can I go from substitute(list(a=x, b=c)) to list(a=substitute(x), b=substitute(c)) (I am also interested in a

Re: [Rd] Best practices in developing package: From a single file

2018-01-30 Thread Hadley Wickham
On Tue, Jan 30, 2018 at 4:55 PM, Duncan Murdoch wrote: > On 30/01/2018 4:30 PM, Kenny Bell wrote: >> >> In response to Duncan regarding the use of roxygen2 from the point of view >> of a current user, I believe the issue he brings up is one of correlation >> rather than causation. > > > Could be.

Re: [Rd] Best practices in developing package: From a single file

2018-01-30 Thread Hadley Wickham
>> There is package.skeleton() in base R as you already mentioned. It drove >> me >> bonkers that it creates packages which then fail R CMD check, so I wrote a >> wrapper package (pkgKitten) with another helper function (kitten()) which >> calls the base R helper and then cleans up it---but otherwi

Re: [Rd] Best practices in developing package: From a single file

2018-02-01 Thread Hadley Wickham
On Thu, Feb 1, 2018 at 4:29 AM, Duncan Murdoch wrote: > On 31/01/2018 6:59 AM, Duncan Murdoch wrote: >> >> On 30/01/2018 11:39 PM, Hadley Wickham wrote: > > [ lots deleted ] >>> >>> Personally, I don't find writing in comments any harder than writing &

[Rd] Base R examples that write to current working directory

2018-03-29 Thread Hadley Wickham
Hi all, Given the recent CRAN push to prevent examples writing to the working directory, is there any interest in fixing base R examples that write to the working directory? A few candidates are the graphics devices, file.create(), writeBin(), writeChar(), write(), and saveRDS(). I'm sure there ar

[Rd] predict.glm returns different results for the same model

2018-04-27 Thread Hadley Wickham
Hi all, Very surprising (to me!) and mystifying result from predict.glm(): the predictions vary depending on whether or not I use ns() or splines::ns(). Reprex follows: library(splines) set.seed(12345) dat <- data.frame(claim = rbinom(1000, 1, 0.5)) mns <- c(3.4, 3.6) sds <- c(0.24, 0.35) dat$wi

Re: [Rd] predict.glm returns different results for the same model

2018-04-27 Thread Hadley Wickham
On Fri, Apr 27, 2018 at 7:28 AM, Duncan Murdoch wrote: > On 27/04/2018 9:25 AM, Hadley Wickham wrote: >> >> Hi all, >> >> Very surprising (to me!) and mystifying result from predict.glm(): the >> predictions vary depending on whether or not I use ns() or

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:00 AM, Gabe Becker wrote: > As of 3.5.0 the ...length() function does exactly what you are asking for. > Before that, I don't know of an easy way to get the length without > evaluation via R code. There may be one I'm not thinking of though, I > haven't needed to do this m

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:18 AM, Duncan Murdoch wrote: > On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: >> >> In R-3.5.0 you can use ...length(): >>> f <- function(..., n) ...length() >>> f(stop("one"), stop("two"), stop("three"), n=7) >>[1] 3 >> >> Prior to that substitute()

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:28 AM, Hadley Wickham wrote: > On Thu, May 3, 2018 at 8:00 AM, Gabe Becker wrote: >> As of 3.5.0 the ...length() function does exactly what you are asking for. >> Before that, I don't know of an easy way to get the length without >> evaluatio

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 9:50 AM, Duncan Murdoch wrote: > On 03/05/2018 11:18 AM, Duncan Murdoch wrote: >> >> On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: >>> >>> In R-3.5.0 you can use ...length(): >>> > f <- function(..., n) ...length() >>> > f(stop("one"), stop("two"), stop("

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-08 Thread Hadley Wickham
On Thu, May 3, 2018 at 11:34 PM, Tomas Kalibera wrote: > On 05/03/2018 11:14 PM, Henrik Bengtsson wrote: >> >> Also, as mentioned in my >> https://stat.ethz.ch/pipermail/r-devel/2012-August/064739.html, when >> not specifying the mode argument, the default on Windows is mode = "w" >> *except* for

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-08 Thread Hadley Wickham
On Tue, May 8, 2018 at 8:15 AM, Hadley Wickham wrote: > On Thu, May 3, 2018 at 11:34 PM, Tomas Kalibera > wrote: >> On 05/03/2018 11:14 PM, Henrik Bengtsson wrote: >>> >>> Also, as mentioned in my >>> https://stat.ethz.ch/pipermail/r-devel/2012-August/0

[Rd] Subsetting the "ROW"s of an object

2018-06-08 Thread Hadley Wickham
Hi all, Is there a better to way to subset the ROWs (in the sense of NROW) of an vector, matrix, data frame or array than this? subset_ROW <- function(x, i) { nd <- length(dim(x)) if (nd <= 1L) { x[i] } else { dims <- rep(list(quote(expr = )), nd - 1L) do.call(`[`, c(list(quote(

Re: [Rd] Subsetting the "ROW"s of an object

2018-06-08 Thread Hadley Wickham
I suspect this will have suboptimal performance since the TRUEs will get recycled. (Maybe there is, or could be, ALTREP, support for recycling) Hadley On Fri, Jun 8, 2018 at 10:16 AM, Berry, Charles wrote: > > >> On Jun 8, 2018, at 8:45 AM, Hadley Wickham wrote: >> >>

Re: [Rd] Subsetting the "ROW"s of an object

2018-06-08 Thread Hadley Wickham
matrix(raw(0), nrow = 5, ncol = 0)[1:3, TRUE] : >>(subscript) logical subscript too long > > OK. But this is easy enough to handle. > >> >> H. >> >> On 06/08/2018 10:29 AM, Hadley Wickham wrote: >>> I suspect this will have suboptimal performance since the

Re: [Rd] Subsetting the "ROW"s of an object

2018-06-08 Thread Hadley Wickham
s 46.3ms On Fri, Jun 8, 2018 at 12:31 PM, Berry, Charles wrote: > > >> On Jun 8, 2018, at 11:52 AM, Hadley Wickham wrote: >> >> On Fri, Jun 8, 2018 at 11:38 AM, Berry, Charles wrote: >>> >>> >>>> On Jun 8, 2018, at 10:37 AM, Hervé Pagè

Re: [Rd] Subsetting the "ROW"s of an object

2018-06-08 Thread Hadley Wickham
On Fri, Jun 8, 2018 at 2:09 PM, Berry, Charles wrote: > > >> On Jun 8, 2018, at 1:49 PM, Hadley Wickham wrote: >> >> Hmmm, yes, there must be some special case in the C code to avoid >> recycling a length-1 logical vector: > > > Here is a version that (I

[Rd] Testing for vectors

2018-07-07 Thread Hadley Wickham
Hi all, Is there are base function that I've missed that tests if an object is a vector in the dimensionality sense, rather than the data structure sense? i.e. something that checks is.null(dim(x)) ? is.vector() is trivially disqualified since it also checks for the presence of non-names attribut

Re: [Rd] Testing for vectors

2018-07-07 Thread Hadley Wickham
On Sat, Jul 7, 2018 at 12:54 PM, Duncan Murdoch wrote: > On 07/07/2018 1:20 PM, Hadley Wickham wrote: >> >> Hi all, >> >> Is there are base function that I've missed that tests if an object is >> a vector in the dimensionality sense, rather than the data s

Re: [Rd] Testing for vectors

2018-07-07 Thread Hadley Wickham
On Sat, Jul 7, 2018 at 1:50 PM, Gabe Becker wrote: > Hadley, > >> >> I was thinking primarily of completing the set of is.matrix() and >> is.array(), or generally, how do you say: is `x` a 1d dimensional >> thing? > > > Can you clarify what you mean by dimensionality sense and specifically 1d > he

Re: [Rd] Testing for vectors

2018-07-08 Thread Hadley Wickham
On Sat, Jul 7, 2018 at 3:48 PM, Ott Toomet wrote: > Thanks, Hadley for bringing this up:-) > > I am teaching R and I can suggest 5 different definitions of 'vector': > > a) vector as a collection of homogeneous objects, indexed by [ ] (more > precisely atomic vector). Sometimes you hear that in R

Re: [Rd] Testing for vectors

2018-07-08 Thread Hadley Wickham
On Sat, Jul 7, 2018 at 11:19 PM, Gabe Becker wrote: > Hadley, > > > On Sat, Jul 7, 2018 at 1:32 PM, Hadley Wickham wrote: >> >> On Sat, Jul 7, 2018 at 1:50 PM, Gabe Becker wrote: >> > Hadley, >> > >> >> >> >> I was thinking prima

[Rd] Is NULL a vector?

2018-07-23 Thread Hadley Wickham
Hi all, Would you generally consider NULL to be a vector? Base R functions are a little inconsistent: ## In favour ``` r identical(as.vector(NULL), NULL) #> [1] TRUE identical(as(NULL, "vector"), NULL) #> [1] TRUE # supports key vector vector generics length(NULL) #> [1] 0 NULL[c(3, 4, 5)] #>

Re: [Rd] Is NULL a vector?

2018-07-23 Thread Hadley Wickham
On Mon, Jul 23, 2018 at 2:17 PM, Duncan Murdoch wrote: > On 23/07/2018 3:03 PM, Hadley Wickham wrote: >> >> Hi all, >> >> Would you generally consider NULL to be a vector? > > > According to the language definition (in the doc directory), it is not: > &

[Rd] vctrs: a type system for the tidyverse

2018-08-06 Thread Hadley Wickham
Hi all, I wanted to share with you an experimental package that I’m currently working on: vctrs, . The motivation for vctrs is to think deeply about the output “type” of functions like `c()`, `ifelse()`, and `rbind()`, with an eye to implementing one strategy throug

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-06 Thread Hadley Wickham
I do want to emphasise that it's a type system, not a oo system, in that coercions are not defined by superclass/subclass relationships. > More thoughts inline. > > On Mon, Aug 6, 2018 at 9:21 AM, Hadley Wickham wrote: >> >> Hi all, >> >> I wanted to share with

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Hadley Wickham
>>> Method dispatch for `vec_c()` is quite simple because associativity and >>> commutativity mean that we can determine the output type only by >>> considering a pair of inputs at a time. To this end, vctrs provides >>> `vec_type2()` which takes two inputs and returns their common type >>> (repres

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Hadley Wickham
> > I now have a better argument, I think: > > > If you squint your brain a little, I think you can see > > that each set of automatic coercions is about increasing > > resolution. Integers are low resolution versions of > > doubles, and dates are low resolution versions of >

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Hadley Wickham
>> So we say that a >> factor `x` has finer resolution than factor `y` if the levels of `y` >> are contained in `x`. So to find the common type of two factors, we >> take the union of the levels of each factor, given a factor that has >> finer resolution than both. > > I'm not so sure. I think a mo

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
On Thu, Aug 9, 2018 at 3:57 AM Joris Meys wrote: > > I sent this to Iñaki personally by mistake. Thank you for notifying me. > > On Wed, Aug 8, 2018 at 7:53 PM Iñaki Úcar wrote: > > > > > For what it's worth, I always thought about factors as fundamentally > > characters, but with restrictions:

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
On Thu, Aug 9, 2018 at 7:54 AM Joris Meys wrote: > > Hi Hadley, > > my point actually came from a data analyst point of view. A character > variable is something used for extra information, eg the "any other ideas?" > field of a questionnaire. A categorical variable is a variable describing > c

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
> > As Gabe mentioned (and you've explained about) the term "type" > > is really confusing here. As you know, the R internals are all > > about SEXPs, TYPEOF(), etc, and that's what the R level > > typeof(.) also returns. As you want to use something slightly > > different, it should be different

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
On Thu, Aug 9, 2018 at 4:26 PM jan Vitek wrote: > > > I'm now confident that I > > can avoid using "type" by itself, and instead always use it in a > > compound phrase (like type system) to avoid confusion. That leaves the > > `.type` argument to many vctrs functions. I'm considering change it to

Re: [Rd] substitute() on arguments in ellipsis ("dot dot dot")?

2018-08-13 Thread Hadley Wickham
Since you're already using bang-bang ;) library(rlang) dots1 <- function(...) as.list(substitute(list(...)))[-1L] dots2 <- function(...) as.list(substitute(...())) dots3 <- function(...) match.call(expand.dots = FALSE)[["..."]] dots4 <- function(...) exprs(...) bench::mark( dots1(1+2, "a", rno

[Rd] conflicted: an alternative conflict resolution strategy

2018-08-23 Thread Hadley Wickham
Hi all, I’d love to get your feedback on the conflicted package, which provides an alternative strategy for resolving ambiugous function names (i.e. when multiple packages provide identically named functions). conflicted 0.1.0 is already on CRAN, but I’m currently preparing a revision (

Re: [Rd] conflicted: an alternative conflict resolution strategy

2018-08-24 Thread Hadley Wickham
On Thu, Aug 23, 2018 at 3:46 PM Duncan Murdoch wrote: > > First, some general comments: > > This sounds like a useful package. > > I would guess it has very little impact on runtime efficiency except > when attaching a new package; have you checked that? It adds one extra element to the search pa

Re: [Rd] conflicted: an alternative conflict resolution strategy

2018-08-24 Thread Hadley Wickham
On Fri, Aug 24, 2018 at 4:28 AM Joris Meys wrote: > > Dear Hadley, > > There's been some mails from you lately about packages on R-devel. I would > argue that the appropriate list for that is R-pkg-devel, as I've been told > myself not too long ago. People might get confused and think this is ab

[Rd] Where does L come from?

2018-08-25 Thread Hadley Wickham
Hi all, Would someone mind pointing to me to the inspiration for the use of the L suffix to mean "integer"? This is obviously hard to google for, and the R language definition (https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Constants) is silent. Hadley -- http://hadley.nz __

Re: [Rd] conflicted: an alternative conflict resolution strategy

2018-08-29 Thread Hadley Wickham
>> conflicted applies a few heuristics to minimise false positives (at the >> cost of introducing a few false negatives). The overarching goal is to >> ensure that code behaves identically regardless of the order in which >> packages are attached. >> >> - A number of packages provide a function t

Re: [Rd] Where does L come from?

2018-08-29 Thread Hadley Wickham
Thanks for the great discussion everyone! Hadley On Sat, Aug 25, 2018 at 8:26 AM Hadley Wickham wrote: > > Hi all, > > Would someone mind pointing to me to the inspiration for the use of > the L suffix to mean "integer"? This is obviously hard to google for, > a

Re: [Rd] ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1

2018-08-30 Thread Hadley Wickham
I think this is an excellent idea as it eliminates a situation which is almost certainly user error. Making it an error would break a small amount of existing code (even if for the better), so perhaps it should start as a warning, but be optionally upgraded to an error. It would be nice to have a f

Re: [Rd] ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1

2018-08-30 Thread Hadley Wickham
On Thu, Aug 30, 2018 at 10:58 AM Martin Maechler wrote: > > > Joris Meys > > on Thu, 30 Aug 2018 14:48:01 +0200 writes: > > > On Thu, Aug 30, 2018 at 2:09 PM Dénes Tóth > > wrote: > >> Note that `||` and `&&` have never been symmetric: > >> > >> TRUE || stop() # re

Re: [Rd] build package with unicode (farsi) strings

2018-08-30 Thread Hadley Wickham
On Thu, Aug 30, 2018 at 2:11 AM Thierry Onkelinx wrote: > > Dear Farid, > > Try using the ASCII notation. letters_fa <- c("\u0627", "\u0641"). The full > code table is available at https://www.utf8-chartable.de It's a little easier to do this with code: letters_fa <- c('الف','ب','پ','ت','ث','ج',

Re: [Rd] True length - length(unclass(x)) - without having to call unclass()?

2018-09-02 Thread Hadley Wickham
For the new vctrs::records class, I implemented length, names, [[, and [[<- myself in https://github.com/r-lib/vctrs/blob/master/src/fields.c. That lets me override the default S3 methods while still being able to access the underlying data that I'm interested in. Another option that avoids (that

[Rd] An update on the vctrs package

2018-11-05 Thread Hadley Wickham
Hi all, I wanted to give you an update on vctrs () since I last bought it up here in August. The biggest change is that I now have a much clearer idea of what vctrs is! I’ll summarise that here, and point you to the documentation if you’re interested in learning more. I’m

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-27 Thread Hadley Wickham
I would recommend reading https://adv-r.hadley.nz/base-types.html and https://adv-r.hadley.nz/s3.html. Understanding the distinction between base types and S3 classes is very important to make this sort of question precise, and in my experience, you'll find R easier to understand if you carefully d

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-28 Thread Hadley Wickham
On Wed, Mar 27, 2019 at 6:27 PM Abs Spurdle wrote: > > > the prison made by ancient design choices > > That prison of ancient design choices isn't so bad. > > I have no further comments on object oriented semantics. > However, I'm planning to follow the following design pattern. > > If I set the c

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Hadley Wickham
The existing behaviour seems inutitive to me. I would consider these invariants for n vector x_i's each with size m: * nrow(rbind(x_1, x_2, ..., x_n)) equals n * ncol(rbind(x_1, x_2, ..., x_n)) equals m Additionally, wouldn't you expect rbind(x_1[i], x_2[i]) to equal rbind(x_1, x_2)[, i, drop = F

Re: [Rd] Puzzled about a new method for "[".

2019-11-04 Thread Hadley Wickham
For what it's worth, I don't think this strategy can work in general, because a class might have attributes that depend on its data/contents (e.g. https://vctrs.r-lib.org/articles/s3-vector.html#cached-sum). I don't think these are particularly common in practice, but it's dangerous to assume that

Re: [Rd] improving the performance of install.packages

2019-11-09 Thread Hadley Wickham
If this is the behaviour you are looking for, you might like to try pak (https://pak.r-lib.org) # Create a temporary library path <- tempfile() dir.create(path) .libPaths(path) pak::pkg_install("scales") #> → Will install 8 packages: #> colorspace (1.4-1), labeling (0.3), munsell (0.5.0), R6 (2

Re: [Rd] class() |--> c("matrix", "arrary") [was "head.matrix ..."]

2019-11-14 Thread Hadley Wickham
On Sun, Nov 10, 2019 at 2:37 AM Martin Maechler wrote: > > > Gabriel Becker > > on Sat, 2 Nov 2019 12:37:08 -0700 writes: > > > I agree that we can be careful and narrow and still see a > > nice improvement in behavior. While Herve's point is valid > > and I understand his

Re: [Rd] Rebuilding and re-checking of downstream dependencies on CRAN Mac build machines

2020-03-26 Thread Hadley Wickham
If I do install.packages("dplyr", type = "source"), I see: Installing package into ‘/Users/hadley/R’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/src/contrib/dplyr_0.8.5.tar.gz' Content type 'application/x-gzip' length 1378766 bytes (1.3 MB) ==

Re: [Rd] object.size vs lobstr::obj_size

2020-03-27 Thread Hadley Wickham
On Fri, Mar 27, 2020 at 10:39 AM Hervé Pagès wrote: > Hi Tomas, > > On 3/27/20 07:01, Tomas Kalibera wrote: > > they provide an over-approximation > > They can also provide an "under-approximation" (to say the least) e.g. > on reference objects where the entire substance of the object is ignored

Re: [Rd] object.size vs lobstr::obj_size

2020-03-27 Thread Hadley Wickham
On Fri, Mar 27, 2020 at 11:08 AM Tomas Kalibera wrote: > On 3/27/20 4:39 PM, Hervé Pagès wrote: > > Hi Tomas, > > > > On 3/27/20 07:01, Tomas Kalibera wrote: > >> they provide an over-approximation > > > > They can also provide an "under-approximation" (to say the least) e.g. > > on reference obj

Re: [Rd] object.size vs lobstr::obj_size

2020-03-27 Thread Hadley Wickham
On Fri, Mar 27, 2020 at 4:01 PM Hervé Pagès wrote: > > > On 3/27/20 12:00, Hadley Wickham wrote: > > > > > > On Fri, Mar 27, 2020 at 10:39 AM Hervé Pagès > <mailto:hpa...@fredhutch.org>> wrote: > > > > Hi Tomas, > > > > On

Re: [Rd] Package development process?

2010-06-17 Thread Hadley Wickham
> The creation of a research compendium can be viewed as > a form of unit testing, and the fact that R has powerful tools > that support this process (Sweave) could be viewed as one of > its outstanding features (relating these comments back to > the topic of this thread). If anything, a research

Re: [Rd] nchar( NA )

2010-06-18 Thread Hadley Wickham
> Value: > >     For ‘nchar’, an integer vector giving the sizes of each element, >     currently always ‘2’ for missing values (for ‘NA’). > > It may be unexpected behavior, but it's *well-documented* unexpected behavior. Oh, that must make it ok then. For a more sensible take: > library(string

Re: [Rd] proposed change to 'sample'

2010-06-20 Thread Hadley Wickham
> I would be more inclined to make sampling from a vector the normal case, > and default x to say 1:max(n, size), forcing users to say sample(n=5) if > sampling from x=1:5 is desired. This could be a manageable change; the > deprecation sequence is a bit painful to think through, though. Don't we

[Rd] Catching Ctrl-C/Esc at R-level

2010-06-29 Thread Hadley Wickham
Hi all, Is it possible to catch when the user presses Ctrl+C/Esc and deal with it at the R level? Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org maili

[Rd] Documenting non-exported objects

2010-06-29 Thread Hadley Wickham
If I don't export an object saved in data/, do I still need to document it? Currently it seems like I do. My namespace file looks like this: export(evaluate) export(parse_all) export(replay) But when I run R CMD check I get: * checking for missing documentation entries ... WARNING Undocumented

[Rd] Tips for debugging: R CMD check examples

2010-06-29 Thread Hadley Wickham
Hi all, Does anyone have any suggestions for debugging the execution of examples by R CMD check? The examples work fine when I run them from a live R prompt, but I get errors when they are run by R CMD check. Thanks, Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of S

Re: [Rd] Tips for debugging: R CMD check examples

2010-06-30 Thread hadley wickham
> R CMD check produces a foo-Ex.R file where foo is the package name. You > could start by sourcing that file in R --vanilla and see where it fails > and also use standard debugging tools in R from there (i.e. drop into a > debugger on error). I knew about the foo-Ex.R file, but unfortunately runn

Re: [Rd] Tips for debugging: R CMD check examples

2010-06-30 Thread Hadley Wickham
> Not a real tip, but when it occurs I immediately > check for namespace issues (which often turn out > to be the origin). Things I do are I agree that namespace issues are often a problem, and are never easy to diagnose - I often find that I've forgotten to export a method definition so other cod

Re: [Rd] Tips for debugging: R CMD check examples

2010-06-30 Thread hadley wickham
> How did you 'run' it?   I suspect you source()d it, not at all the same > thing.  I have yet to encounter a problem which > > R --vanilla < foo-Ex.R > > or perhaps > > env LANGUAGE=en R --vanilla --encoding=latin1 < foo-Ex.R > > did not reproduce. Thanks, that was exactly what I was looking for.

Re: [Rd] Attributes of 1st argument in ...

2010-07-03 Thread Hadley Wickham
Hi Dan, Is there a reason you can't change the function to f <- function(x, ...) {} ? Hadley On Fri, Jul 2, 2010 at 4:26 PM, Daniel Murphy wrote: > R-Devel: > > I am trying to get an attribute of the first argument in a call to a > function whose formal arguments consist of dots only and do s

Re: [Rd] Creating an environment with attributes in a package

2010-07-16 Thread Hadley Wickham
On Fri, Jul 16, 2010 at 2:08 PM, Jon Clayden wrote: > Dear all, > > I am trying to create an environment object with additional attributes, viz. > > Foo <- structure(new.env(), name="Foo") > > Doing this in a standard session works fine: I get the environment > with attr(,"name") set as expected.

Re: [Rd] parent.frame(1) of a S4 method is not a calling environment.

2010-08-17 Thread Hadley Wickham
On Tuesday, August 17, 2010, Vitaly S. wrote: > Duncan Murdoch writes: > >> Vitaly S. wrote: >>> Martin Morgan writes: >>> > So,  can I be sure that for such functions parent.frame(2) will always > work? > What are the additional rules? > callNextMethod() will cause additio

Re: [Rd] How do you make a formal "feature" request?

2010-08-21 Thread Hadley Wickham
> A report() function analogous to the plot() function that makes it easy to > generate a report from a table of data. This should not be in some auxiliary > package, but part of the core R just like plot(). As a long time SAS user I > cannot believe R does not have this. Please don't give me an

Re: [Rd] No RTFM?

2010-08-21 Thread Hadley Wickham
> previous suggestion by a regular contributor.  I still think a better > response is not to escalate:  Either ignore the post or say something like, > "I don't understand your question.  Please provide a self-contained minimal > example as suggested in the Posting Guide ... ." I agree wholehearte

Re: [Rd] No RTFM?

2010-08-21 Thread Hadley Wickham
> Regarding length, the portion at the end of every r-help message (but > this does not appear at the end of r-devel messages or the messages > of other lists concerning R): > >   "provide commented, minimal, self-contained, reproducible code." > > It was intended to provide a one line synopsis of

[Rd] require is to suggests as what is to imports?

2010-08-24 Thread Hadley Wickham
Hi all, If a package suggests another package in its description, you can check it at runtime with requires. How do you do check if a package is available without loading it, if you only want to access one function in the package namespace. Thanks, Hadley -- Assistant Professor / Dobelman Fam

Re: [Rd] require is to suggests as what is to imports?

2010-08-25 Thread Hadley Wickham
On Tue, Aug 24, 2010 at 3:50 PM, Prof Brian Ripley wrote: > On Tue, 24 Aug 2010, Hadley Wickham wrote: > >> Hi all, >> >> If a package suggests another package in its description, you can >> check it at runtime with requires.  How do you do check if a package &g

Re: [Rd] require is to suggests as what is to imports?

2010-08-25 Thread Hadley Wickham
> But thereby clobber your users with the run-time cost of > installed.packages() (which can take several minutes on some Windows > systems, and just took ca 12secs on my fastest Linux server with 3000 > packages installed).  If you want to take this route (is a package > installed?), see the 'Note

Re: [Rd] require is to suggests as what is to imports?

2010-08-25 Thread Hadley Wickham
On Tue, Aug 24, 2010 at 6:55 PM, Henrik Bengtsson wrote: > isPackageInstalled <- function(package, ...) { >  path <- system.file(package=package); >  (path != ""); > } > > taken from R.utils (which also has a isPackageLoaded()). Nice quick hack (subject to caveats Brian mentions). Thanks! Hadl

[Rd] NEWS and readNEWS

2010-08-27 Thread Hadley Wickham
readNEWS() states: Read R's ‘NEWS’ file or a similarly formatted one. This is an experimental feature, new in R 2.4.0 and may change in several ways and news() also indicates that this tool is supposed to work with non-R news files. However, I've not been able to get readNEWS to

Re: [Rd] NEWS and readNEWS

2010-08-30 Thread Hadley Wickham
>>   * s.post <- " SERIES NEWS" >>   * s.pre <- "^[\t ]*CHANGES IN R VERSION " > >> Is this a bug or is the documentation incorrect? > > readNEWS() is really for such 3-level files, but then R itself will move > to an 2-level Rd format in R 2.12.0. > > Use news() to read package news files. Ah, ok

[Rd] S3 method for package listed in suggest/enhance

2010-09-01 Thread Hadley Wickham
Hi all, The profr package provides a method for displaying its output with ggplot: ggplot.print. You don't need this ggplot2 to use profr, so ggplot2 is listed under enhances in the DESCRIPTION file. If I have just S3method(ggplot, profr) in my NAMESPACE, then I get: ** testing if installed pac

[Rd] License of R manuals

2010-09-29 Thread Hadley Wickham
Hi all, Under what license are the R manuals (R language definition etc) released? They are not mentioned explicitly in license() and have no license information in the individual documents. Does this mean that they are released under GPL-2? If so, what does that mean, given that they aren't so

Re: [Rd] License of R manuals

2010-09-29 Thread Hadley Wickham
> Hmm, well... I have always understood it so that: (a) yes, it's GPL-2 (what > else could it be) and (b) it means that the restrictions of GPL apply insofar > as they make sense, e.g., you can pick it apart and reuse it in other GPL-2 > or compatible products, but not take it proprietary. Upon

[Rd] Eval and the enclos argument

2010-10-02 Thread Hadley Wickham
Hi all, I'm trying to understand the default value of the enclos argument of eval: enclos = if(is.list(envir) || is.pairlist(envir)) parent.frame() else baseenv() Why isn't it just enclos = parent.frame() given that enclos is only meaningful (given my reading of the documentation) when env

Re: [Rd] Eval and the enclos argument

2010-10-02 Thread Hadley Wickham
On Sat, Oct 2, 2010 at 8:18 AM, Duncan Murdoch wrote: > On 02/10/2010 7:57 AM, Hadley Wickham wrote: >> >> Hi all, >> >> I'm trying to understand the default value of the enclos argument of eval: >> >>  enclos = if(is.list(envir) || is.pairlist(envir)

[Rd] What do you call the value that represents a missing argument?

2010-10-08 Thread Hadley Wickham
Hi all, What's the official name for the value that represents a missing argument? e.g. formals(plot)$x str(formals(plot)$x) deparse(formals(plot)$x) is.symbol(formals(plot)$x) What's the correct way to create an object like this? (for example if you are manipulating the formals of a function t

Re: [Rd] What do you call the value that represents a missing argument?

2010-10-09 Thread Hadley Wickham
> It is a 'dotted pair list' But: > is.pairlist(formals(plot)$x) [1] FALSE Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.e

Re: [Rd] Rbuildignore and mercurial

2010-10-27 Thread Hadley Wickham
>  I've changed to Mercurial for my working copies of survival for a number or > resons not relevant to this post.  When I do R CMD check, I get some warnings > about certain files in the .hg directory with odd names.  I've added the > following 2 lines to my .Rbuildignore file without effect > ^

Re: [Rd] Roxygen: @example tag does not work for me

2010-11-04 Thread Hadley Wickham
> I thought that @example would take the R code in "tests/foo.R" (this file > also exists) and append it to the .Rd-file. However, there is no > \examples{...} section in my roxygen-processed .Rd-file after running > roxygenize(). It just seems as if @example is just neglected. Should I put > the f

[Rd] col2rgb feature request

2010-11-08 Thread Hadley Wickham
Small feature request for col2rgb: could it preserve missing values? Currently: > col2rgb(NA) [,1] red255 green 255 blue 255 Which is frustrating when you're working with vectors of colors that might include transparent colours. Hadley -- Assistant Professor / Dobelman Family Juni

Re: [Rd] SEXPs and slots

2010-11-15 Thread Hadley Wickham
> 2.  Any good references/resources for developing R?  Nearly all the > documents I've found are for programming R as a user, not as a developer.  I > have copies of the documentation, which are very helpful, but it'd be > helpful to have additional resources to fill in their gaps. The best advice

Re: [Rd] Create NAMESPACE file as 'package.skeleton()' would do

2010-11-15 Thread Hadley Wickham
If you're using roxygenise, explicitly tag functions that you want to export with @export. Hadley On Mon, Nov 15, 2010 at 5:11 PM, Janko Thyson wrote: > Hi there, > > > > is there a way to create a NAMESPACE file based on Rd-files (or whatever is > needed in order to apply the regular expression

  1   2   3   4   5   6   7   8   >