Re: [Rd] R 3.0, Rtools3.0,l Windows7 64-bit, and permission agony

2013-04-21 Thread Hadley Wickham
Because it can conflict with other Windows software unless you add a layer over it. What other popular software that runs on Windows has these problems? I can't think of any. The closest I can come up with was that for a short time after git was ported to Windows it would change the font

Re: [Rd] R 3.0, Rtools3.0,l Windows7 64-bit, and permission agony

2013-04-21 Thread Hadley Wickham
Because it can conflict with other Windows software unless you add a layer over it. What other popular software that runs on Windows has these problems? I can't think of any. The closest I can come up with was that for a short time after git was ported to Windows it would change the font

Re: [Rd] R 3.0, Rtools3.0,l Windows7 64-bit, and permission agony

2013-04-21 Thread Hadley Wickham
PS. Hadley, is this what you meant when you wrote Better solutions (e.g. Rstudio and devtools) temporarily set the path on when you're calling R CMD *., or those approaches are only when you call 'R CMD' from the R prompt? I believe the latter, but I just want to make sure I didn't miss

Re: [Rd] R 3.0, Rtools3.0,l Windows7 64-bit, and permission agony

2013-04-20 Thread Hadley Wickham
Just curious: how often do you use the Windows find command? We have put instructions in place for people to run the install process with a renamed Rtools find command (which I think is the only conflict). The issue is that more users who want to use the command line commands are familiar

Re: [Rd] R 3.0, Rtools3.0,l Windows7 64-bit, and permission agony

2013-04-20 Thread Hadley Wickham
As far as I can tell, the steps you are recommending take place in an earlier build step. This would require the user who wants to do this to rebuild Rtools in its entirety, which is more trouble than it is likely to be worth. Especially when you can avoid the problem by using your own batch

[Rd] Subtle bug in write.csv

2013-04-04 Thread Hadley Wickham
There's a subtle bug in write.csv - write.csv(mtcars, mtcars.csv, row = FALSE) # Error in write.table(mtcars, mtcars.csv, row = FALSE, col.names = NA, : # col.names = NA makes no sense when row.names = FALSE write.csv(mtcars, mtcars.csv, row.names = FALSE) # Works i.e. the special evaluation

[Rd] Documentation error in subsitute

2013-04-03 Thread Hadley Wickham
Hi all, The documentation for substitute currently reads: Substitution takes place by examining each component of the parse tree as follows: If it is not a bound symbol in ‘env’, it is unchanged. If it is a promise object, i.e., a formal argument to a function or explicitly created using

Re: [Rd] source, sys.source and error line numbers

2013-03-26 Thread Hadley Wickham
It turns out the reason for this is pretty simple: sys.source does: for (i in exprs) eval(i, envir) where source basically does n - length(exprs) for (i in seq_len(n)) eval(expr[i], envir) so the problem is presumably related to the way that for strips attributes. Hadley On Tue, Mar 19, 2013

Re: [Rd] Deprecating partial matching in $.data.frame

2013-03-20 Thread Hadley Wickham
On Wed, Mar 20, 2013 at 11:26 AM, peter dalgaard pda...@gmail.com wrote: On Mar 20, 2013, at 16:59 , William Dunlap wrote: Will you be doing the same for attribute names? Not at this point. It would be really nice to have consistent behaviour across argument names, attributes, lists and

[Rd] Structure not deparsed correctly when printing calls

2013-03-20 Thread Hadley Wickham
z - substitute(f(x), list(x = data.frame(y = 1))) z # f(list(y = 1)) str(z) # language f(structure(list(y = 1), .Names = y, row.names = c(NA, -1L), class = data.frame)) dput(z) # f(structure(list(y = 1), .Names = y, row.names = c(NA, -1L), class = data.frame)) Hadley -- Chief Scientist,

Re: [Rd] Snippets from other packages/ License

2013-03-14 Thread Hadley Wickham
If you wish to fork the original code and include the code directly in your package, then your package will also need to be GPL=3, you will need to list the authors of that code as Contributors in your DESCRIPTION file, and I would strongly recommend that you place this code in a separate .R

Re: [Rd] double bracket stripping names

2013-02-26 Thread Hadley Wickham
Yes, as Brian said. And this makes sense: the names are a property of the container, not a property of the contents. Using single brackets creates a new container with a subset of the elements. Using double brackets extracts an element. The fact that there's no way to hold a number other

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Hadley Wickham
To summarize, it appears that the only way to call functions from a suggested package is by using either 'require' (which will dynamically attach it) or the double colon method. Is this something that should be mentioned in R-exts? Except the double colon method doesn't work (i.e. does not

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Hadley Wickham
loadNamespaces loads but does not attach the package. Suggests: is enough to quieten the warning with ~/tmp$ R --version R Under development (unstable) (2013-02-21 r62017) -- Unsuffered Consequences This is consistent with RShowDoc(R-exts) section 1.1.1 Namespaces accessed by the ‘::’

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Hadley Wickham
Hi Davor, To the best of my knowledge, there's only one way to use functions from a suggested package: with require: if (require(suggested_package)) { function_from_suggested_package() } else { stop(suggested package not installed) } Unfortunately I don't think there's any way to use a

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Hadley Wickham
On Friday, February 22, 2013, Simon Urbanek wrote: On Feb 22, 2013, at 9:13 PM, Hadley Wickham wrote: Hi Davor, To the best of my knowledge, there's only one way to use functions from a suggested package: with require: if (require(suggested_package

Re: [Rd] Passing R code from webpage

2013-02-18 Thread Hadley Wickham
No one yet has mentioned shiny (http://www.rstudio.com/shiny/); it allows you to get up and prototyping quickly, and we're working on ways to make it just as easy to scale to multiple users (currently it's possible, but you have to be willing to get your hands dirty configuring servers etc).

[Rd] quote() vs quote(expr=)

2013-02-18 Thread Hadley Wickham
Hi all, I think there's a small buglet in quote: str(quote()) # Error in quote() : 0 arguments passed to 'quote' which requires 1 str(quote(expr = )) # symbol I bring this up because this seems like the most natural way of capturing the missing symbol with pure R code, compared to substitute()

Re: [Rd] quote() vs quote(expr=)

2013-02-18 Thread Hadley Wickham
If there is a bug here, I'd say that it is in str(), revealing the implementation of the missing value as the symbol ``, Yes, a fix to str would be nice too :) which we otherwise try not to disclose to R code, e.g. as.symbol() Error in as.symbol() : attempt to use zero-length variable

Re: [Rd] quote() vs quote(expr=)

2013-02-18 Thread Hadley Wickham
On Mon, Feb 18, 2013 at 10:35 AM, peter dalgaard pda...@gmail.com wrote: On Feb 18, 2013, at 17:04 , Hadley Wickham wrote: quote(expr =) returning missing seems like the right thing to me, quote() throwing an error does not, because it violates the usual semantics where f(x = ) is equivalent

Re: [Rd] quote() vs quote(expr=)

2013-02-18 Thread Hadley Wickham
them if missing()'s behavior changes. Basically this internal thing _shouldn't_ be visible at R level, and if we ever figure out how to make that happen it will. Best, luke On Mon, 18 Feb 2013, Hadley Wickham wrote: Hi all, I think there's a small buglet in quote: str(quote

Re: [Rd] quote() vs quote(expr=)

2013-02-18 Thread Hadley Wickham
token (that happens to be used for a couple of different things) is a quirk; if you look at the code I use you can see why it is a quirk. Cleaning this up will help computing on the language (at least that is the hope). luke On Mon, 18 Feb 2013, Hadley Wickham wrote: In general, should we

[Rd] Including modified R source code in a package

2013-02-18 Thread Hadley Wickham
Hi all, I would like to include a function that I have made by modifying an existing R function (bw.SJ and corresponding code in bandwidths.c). The header of bandwidths.c states: /* * R : A Computer Language for Statistical Data Analysis * bandwidth.c by W. N. Venables and B. D. Ripley

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Hadley Wickham
On Sat, Feb 16, 2013 at 12:24 AM, Bert Gunter gunter.ber...@gene.com wrote: As there has been no response to this ... Why not simply: g - substitute(f(x),list(f=function(x){x+1})) ## with curly braces g function (x) { x + 1 }(x) x - 2 eval(g) [1] 3 Thomas Lumley sent me a similar

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Hadley Wickham
This is a little tricky for the deparser. It sees a call to a function which was determined by an expression. Sometimes you want parens, sometimes you don't. For example, if getfun(y) returns a function, it's clearer to display a call as getfun(y)(x) than (getfun(y))(x). I'll see if I can

Re: [Rd] Matrix does not build with R trunk since Oct.

2013-02-16 Thread Hadley Wickham
Although it goes a long way, it doesn't always work -- it assumes that the directory structure did not change in the project between the revisions - distclean may not clean things that have changed since you updated the SVN (note that to address that you should run distclean *before* the

[Rd] match.call() and missing arguments in ...

2013-02-15 Thread Hadley Wickham
Hi all, Is this expected behaviour or a bug in match.call? f - function(x, ...) { g - function(...) match.call() g(x = x, ...) } f(x = 1, y = ) # g(x = x, y = ..1) Hadley -- Chief Scientist, RStudio http://had.co.nz/ __ R-devel@r-project.org

[Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-15 Thread Hadley Wickham
e.g. substitute(f(x), list(f = function(x) x + 1)) # function (x) # x + 1(x) An extra pair of parentheses would really help: (function(x) x + 1)(x) (Better indenting etc would be nice, but not necessary for correct understand of the code) Hadley -- Chief Scientist, RStudio http://had.co.nz/

Re: [Rd] Private environments and/or assignInMyNamespace

2013-02-12 Thread Hadley Wickham
Here my question: Would it be an option to place the widgets in a private environment of my plugin package (then I would have to learn how to create one and work with it), or won't they be found that way? It sounds like you want to maintain state across function calls within your package, and

Re: [Rd] Trouble building package using R in development

2013-01-18 Thread Hadley Wickham
To what end is the --vanilla here? Writing R Extensions says that R CMD check (and R CMD build) are invoked via R --vanilla so that would seem redundant, although my experience from several hours working this through today suggests there is a difference between R --vanilla CMD check and R CMD

Re: [Rd] Trouble building package using R in development

2013-01-16 Thread Hadley Wickham
To circumvent this, I check using: R --no-init-file CMD check foo_1.0.tar.gz In devtools, we take considerable care to match the R you're running with the R you're checking in, so we also set the following environmental variables: env - c( LC_ALL = C, R_LIBS = paste(.libPaths(),

[Rd] Opening and closing quartz graphic device crashes R

2012-11-28 Thread Hadley Wickham
replicate(1000, {dev.new(); dev.off()}) R(83204,0xacdc1a28) malloc: *** mmap(size=16777216) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug R(83204,0xacdc1a28) malloc: *** mmap(size=16777216) failed (error code=12) *** error: can't

Re: [Rd] built-in NAMED(obj) from within R

2012-11-09 Thread Hadley Wickham
The goal is to ascertain whether a copy of an object has been made. Then : ?tracemem One demonstration of using both together is here : http://stackoverflow.com/a/10312843/403310 Note that tracemem detects duplications (in a technical R sense), not copies - i.e. x - 1:10

Re: [Rd] built-in NAMED(obj) from within R

2012-11-09 Thread Hadley Wickham
On Friday, November 9, 2012, Simon Urbanek wrote: On Nov 9, 2012, at 8:00 AM, Hadley Wickham wrote: The goal is to ascertain whether a copy of an object has been made. Then : ?tracemem One demonstration of using both together is here : http://stackoverflow.com

[Rd] Ops.data.frame

2012-11-05 Thread Hadley Wickham
Hi all, Where are the semantics for Ops.data.frame documented? I've tried looking in ?Ops.data.frame, ?data.frame, the R language definition (by searching for data frame), and An Introduction to R (similarly), but haven't found anything. What am I missing? Hadley -- RStudio / Rice University

Re: [Rd] if(!CRAN()){...}

2012-11-01 Thread Hadley Wickham
You're writing to the wrong place: you should be asking CRAN this question. Their email is c...@r-project.org. They generally don't discuss their operations in R-devel. Who is CRAN? Is that publicly available information? Hadley -- RStudio / Rice University http://had.co.nz/

Re: [Rd] There is pmin and pmax each taking na.rm, how about psum?

2012-10-30 Thread Hadley Wickham
Is there a case to add psum? Or have I missed something. If psum, then why not pdiff (-), pprod (*) and precip (/) ? And similarly, what about equivalent functions for ^, %%, %/%, , and | ? Hadley -- RStudio / Rice University http://had.co.nz/ __

Re: [Rd] install.packages() fails if .libPaths() set

2012-10-30 Thread Hadley Wickham
* installing *source* package ‘relations’ ... ... ** testing if installed package can be loaded *** arch - i386 Error : package ‘sets’ required by ‘relations’ could not be found Error: loading failed Execution halted *** arch - x86_64 Error : package ‘sets’ required by ‘relations’ could

Re: [Rd] Class generator functions for reference classes

2012-10-30 Thread Hadley Wickham
As of rev. 61035 in r-devel, setRefClass() now returns a generator function, as setClass() has done since 2.15.0. The convenient style is now: mEdit - setRefClass(mEdit,..) xx - mEdit(data = xMat) instead of xx - mEdit$new(data = xMat) The returned object still has fields and

[Rd] install.packages() fails if .libPaths() set

2012-10-29 Thread Hadley Wickham
Reproducible example: dir.create(test) .libPaths(test) install.packages(relations, type = source) Fails with: ... * installing *source* package ‘relations’ ... ... ** testing if installed package can be loaded *** arch - i386 Error : package ‘sets’ required by ‘relations’ could not be found

[Rd] Unevaluated .Call

2012-10-11 Thread Hadley Wickham
Hi all, Is there an equivalent to .Call that passes the unevaluated arguments? (e.g. like the equivalent of .Interval + eval = 10 in names.c) If not, are there any disadvantages to doing something like this? myfun - function(...) { .Call(myfun, match.call(), parent.env()) } Thanks! Hadley

Re: [Rd] Capturing environment associated with a promise

2012-10-09 Thread Hadley Wickham
Promises are an implementation detail -- we need to be able to change them, optimize them away, etc, so there is a limit on what we want to expose. Allowing a query of whether a binding is delayed or not should be OK but would want to think that through more carefully before committing to

Re: [Rd] Capturing environment associated with a promise

2012-10-09 Thread Hadley Wickham
Both of these are possible in C. See: https://stat.ethz.ch/pipermail/r-devel/2007-September/046943.html Cool, thanks. It shows how to query an object to see if its a promise and but rather than extract the environment it shows how to copy a promise without evaluating it; however, it was

[Rd] Capturing environment associated with a promise

2012-10-08 Thread Hadley Wickham
Hi all, It's possible to capture the expression associated with a promise (using substitute). Is there any way to capture the environment associated with a promise? Similarly, is there any way to tell if something is a promise without accidentally evaluating it? Thanks! Hadley -- RStudio /

[Rd] Creating functions programmatically

2012-10-03 Thread Hadley Wickham
Hi all, A function has three components: arguments, body and environment. Is there no base function that allows us to create a function from those three components? The best I could come up with is: make_function - function(args, body, env = parent.frame()) { args - as.pairlist(args)

Re: [Rd] Creating functions programmatically

2012-10-03 Thread Hadley Wickham
Am I missing a built in way to do this? Also, is there a built in equivalent to my mquote (= multiquote, for producing a named list of quoted inputs)? Oops, built in equivalent to mquote is alist. (It would be really handy if that was referenced from quote) Hadley -- RStudio / Rice

Re: [Rd] Creating functions programmatically

2012-10-03 Thread Hadley Wickham
There is: it is `function`. The parser converts your function definitions into a call to it. (It has 3 arguments: the formals, the body, and the srcref. The environment is added when it is evaluated.) So your make_function below is pretty similar (but because `function` is primitive,

Re: [Rd] Creating functions programmatically

2012-10-03 Thread Hadley Wickham
On Wed, Oct 3, 2012 at 9:33 AM, Gabriel Becker gmbec...@ucdavis.edu wrote: Hadley, You could do this: make_fun = function(args, body, env) { f = function() formals(f) = args body(f) = body environment(f) = env f } If for some reason using function() itself as Duncan suggested won't

Re: [Rd] Creating functions programmatically

2012-10-03 Thread Hadley Wickham
I think `function` does not eval its arguments, and it demands a pairlist. So this works: f - eval(substitute(`function`(args, body), list(args=as.pairlist(alist(a=1)), body=quote(a+1 The other thing to notice is a syntax difference between function and ordinary calls: when writing

Re: [Rd] How to build a list with missing values? What is missing, anyway?

2012-10-03 Thread Hadley Wickham
On Wed, Oct 3, 2012 at 9:37 PM, Peter Meilstrup peter.meilst...@gmail.com wrote: This is tangentially related to Hadley's question. Suppose I'm building a function programmatically; I have assembled an expression for the body and I know the names of the arguments it wants to take. Suppose I

Re: [Rd] CRAN test / avoidance

2012-09-19 Thread Hadley Wickham
The question becomes: how does information get passed along to indicate things that may take a long time to run. The discussion so far has focused on developers setting, or using, some flags to indicate tests and examples that take a long time. Another option would be to have the check/build

Re: [Rd] if(--as-cran)?

2012-09-06 Thread Hadley Wickham
It was pointed out to me by a member of CRAN that detecting --as-cran is insufficient. CRAN only runs incoming tests with settings equivalent to that. The daily tests use different options. I don't know what those are, and CRAN is unwilling to discuss their internal policies on this list.

Re: [Rd] Environment when NextMethod is used

2012-09-03 Thread Hadley Wickham
Any ideas? Is this a big or a deliberate feature? Hadley On Saturday, September 1, 2012, Winston Chang wrote: I'm running into some hard-to-understand behavior with the evaluation environment when NextMethod is used. I'm using square-bracket indexing into objects, and the evaluation

Re: [Rd] if(--as-cran)?

2012-09-03 Thread Hadley Wickham
| Hi, see thread [Rd] Proposal: Mechanism for controlling the amount of | testing 'R CMD check' performs on April 8, 2012: | | https://stat.ethz.ch/pipermail/r-devel/2012-April/063809.html Good proposal, somehow I missed that at the time. Something like this ought be to implemented in R

Re: [Rd] how to keep the documents of private functions private

2012-08-25 Thread Hadley Wickham
To provide some background, a more general question is how to manage unexported (private) functions in an R package. I need to call them during the developing phase or even after the package is released (e.g., for debugging purpose or they may be needed by new functions), but I don’t want

Re: [Rd] rdyncall fears removal from CRAN

2012-08-20 Thread Hadley Wickham
This is also very relevant for devtools. There have been some recent changes to the in-development version of devtools, so that it loads development packages into a namespace. Previously, it didn't use namespaces, but now that it does, it much more closely approximates normal package loading

Re: [Rd] Quiz: How to get a named column from a data frame

2012-08-18 Thread Hadley Wickham
On Sat, Aug 18, 2012 at 10:03 AM, Martin Maechler maech...@stat.math.ethz.ch wrote: Today, I was looking for an elegant (and efficient) way to get a named (atomic) vector by selecting one column of a data frame. Of course, the vector names must be the rownames of the data frame. Ok, here is

[Rd] chown, chgrp?

2012-08-14 Thread Hadley Wickham
Hi all, Is there an R wrapper for chown/chgrp (a la Sys.chmod)? I couldn't find one with a few minutes of searching, but it seems like a curious omission. Thanks, Hadley -- Assistant Professor Department of Statistics / Rice University http://had.co.nz/

Re: [Rd] Rconfig.h unsupported architectures

2012-07-29 Thread Hadley Wickham
It would appear to be the stock Lion compiler. I can compile biarch with that and a current R. As /Library/Frameworks/R.framework/Resources/include/Rconfig.h in its entirety is the following, the only obvious way to reach the #error would be if __i386__ somehow got undefined. Or the

Re: [Rd] Rconfig.h unsupported architectures

2012-07-27 Thread Hadley Wickham
Actually, probably not the issue. You are getting it from one of R's headers so it may have gotten there while you configured R on your machine. Which I didn't do, since I got a pre-built binary from CRAN. I guess I'll try re-installing and hope the problem goes away. Hadley -- Assistant

[Rd] Version of substitute that evaluates it's first argument

2012-07-27 Thread Hadley Wickham
Hi all, Does there already exist a version of substitute that evaluates it's first argument? (i.e. it accepts an already quoted expression). This seems like something that's pretty handy, but I haven't found any existing function to do it: substitute_e - function(expr, env) {

[Rd] Rconfig.h unsupported architectures

2012-07-25 Thread Hadley Wickham
Hi all, Recently, when compiling R packages containing C code, I've started getting the following error: * installing to library ‘/Users/hadley/R’ * installing *source* package ‘appdirs’ ... ** Creating default NAMESPACE file ** libs *** arch - i386 gcc -arch i386 -std=gnu99

[Rd] Understanding tracemem

2012-07-12 Thread Hadley Wickham
Hi all, I've been trying to get a better handle on what manipulations lead R to duplicate a vector, creating small experiments and using tracemem to observe what happens (all in 2.15.1). That's lead me to a few questions, illustrated using the snippet below. x - 1:10 tracemem(x) # [1]

Re: [Rd] Understanding tracemem

2012-07-12 Thread Hadley Wickham
Read the help carefully as to what 'copy' means: When an object is traced any copying of the object by the C function ‘duplicate’ produces a message to standard output, as does type coercion and copying when passing arguments to ‘.C’ or ‘.Fortran’. If you want to

Re: [Rd] Understanding tracemem

2012-07-12 Thread Hadley Wickham
But does this? z - as.list(x) z$a - 11 Yes of course, as z is now of length 11. There is no provision in R to extend a vector except by creating a new one. (Well, there is at C level but I think it is not currently used.) I guess a better example is z - list(a = 1:1e6, b = runif(1e6))

Re: [Rd] Understanding tracemem

2012-07-12 Thread Hadley Wickham
The list gets copied, but do a and b, or does the new list point to the existing locations? The following test suggests that it's a deep copy. x - 1:1e7 z - list(a = x) system.time(replicate(100, z$b - 1L)) / 100 # ~ 0.05s system.time(replicate(100, x[1e6 + 1L] - 1L)) / 100 # ~ 0.04s

[Rd] Modifying a list: what gets copied?

2012-07-12 Thread Hadley Wickham
Hi all, In my continued effort to understand when and what R copies, I've designed a small experiment to try and figure out what goes on when a list gets copied - is it a shallow copy or a deep copy. I believe the following experiment isolates the difference: options(digits = 2) powers - 4:6 n -

Re: [Rd] Incompatible methods for overloaded operator

2012-06-20 Thread Hadley Wickham
from ?groupGeneric under 'Ops' (of which + is one)          used.  If different methods are found, there is a warning          about 'incompatible methods': in that case or if no method is          found for either argument the internal method is used. which doesn't really explain why it

Re: [Rd] Curry: proposed new functional programming, er, function.

2012-05-25 Thread Hadley Wickham
I've been playing around with this for a while. One flaw I found - it doesn't handle nested Curries very well (the naive implementation in roxygen/functional does). That's easily fixed: Curry - function(FUN, ...) { args - match.call(expand.dots = FALSE)$... args$... - as.name(...) env

Re: [Rd] Curry: proposed new functional programming, er, function.

2012-05-25 Thread Hadley Wickham
On Fri, May 25, 2012 at 3:14 PM, Yike Lu yikelu.h...@gmail.com wrote: So here's the way I'm reading this: Original: curry_call is the function body you're constructing, which is itself just a one liner which calls the symbol FUN with the appropriate substitutions. Yup. With a bit more

[Rd] Decompressing raw vectors in memory

2012-05-02 Thread Hadley Wickham
Hi all, I'm struggling to decompress a gzip'd raw vector in memory: content - readBin(http://httpbin.org/gzip;, raw, 1000) memDecompress(content, type = gzip) # Error in memDecompress(content, type = gzip) : # internal error -3 in memDecompress(2) I'm reasonably certain that the file is

Re: [Rd] Decompressing raw vectors in memory

2012-05-02 Thread Hadley Wickham
I'm struggling to decompress a gzip'd raw vector in memory: content- readBin(http://httpbin.org/gzip;, raw, 1000) memDecompress(content, type = gzip) # Error in memDecompress(content, type = gzip) : #  internal error -3 in memDecompress(2) I'm reasonably certain that the file is correctly

Re: [Rd] Decompressing raw vectors in memory

2012-05-02 Thread Hadley Wickham
Well, it seems what you get there depends on the client, but I did tystie% curl -o foo http://httpbin.org/gzip; tystie% file foo foo: gzip compressed data, last modified: Wed May  2 17:06:24 2012, max compression and the final part worried me: I do not know if memDecompress() knows about

Re: [Rd] Decompressing raw vectors in memory

2012-05-02 Thread Hadley Wickham
I understand the desire not to have any dependency on additional packages, and I have no desire to engage in any mine's better exchanges. So write this just for the record. The gzunzip() function handle this. Funnily enough I just discovered that RCurl already handles this: you just need to

Re: [Rd] R datasets ownership(copyright) and license

2012-04-03 Thread Hadley Wickham
2. we considered all datasets factual data thus not copyrightable (in   USA? around the globe?) This is definitely true in the US, but not true globally. I have no idea under which jurisdiction a lawsuit would apply. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of

Re: [Rd] R datasets ownership(copyright) and license

2012-04-03 Thread Hadley Wickham
I somewhat agree with Spencer -- as I have mentioned, the recent precedence with tz database shows that such claims would not be taken as ungrounded right away and things could easily go all the way to court -- and that might be a really costly endeavor regardless who is right or wrong.  

Re: [Rd] CRAN policies

2012-03-29 Thread Hadley Wickham
Most of that stuff is already in codetools, at least when it is checking functions with checkUsage().  E.g., arguments of ~ are not checked.  The  expr argument to with() will not be checked if you add  skipWith=FALSE to the call to checkUsage.   library(codetools)  

Re: [Rd] CRAN policies

2012-03-27 Thread Hadley Wickham
I have been wondering if it is possible to automate the checking process to reduce human efforts, e.g. automatically check the packages submitted to FTP, and send the package maintainer an email in case of warnings or errors (otherwise just move it to CRAN); package maintainers can appeal for

Re: [Rd] CRAN policies

2012-03-27 Thread Hadley Wickham
On Tue, Mar 27, 2012 at 6:52 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: CRAN has for some time had a policies page at http://cran.r-project.org/web/packages/policies.html and we would like to draw this to the attention of package maintainers.  In particular, please Thanks for the

[Rd] Substitute adds id attribute?

2012-03-20 Thread Hadley Wickham
Hi all, I can't figure out how to make this problem easily reproducible, but I can demonstrate it very simply, so I hoped someone might be able to suggest a place to start: f - function(x) substitute(x) f(x) x f(mpg) mpg attr(,id) [1] 11 It works as expected in a clean R session: f -

Re: [Rd] Substitute adds id attribute?

2012-03-20 Thread Hadley Wickham
Well, yes; you can get there more quickly as follows: x - as.name(foo) attr(x,id) - 7913 x foo attr(,id) [1] 7913 substitute(foo) foo attr(,id) [1] 7913 I.e. if you ever put an attribute on a symbol, it stays there forever. The fix is probably to forbid setting attributes on

Re: [Rd] Converting expression to a function

2012-03-19 Thread Hadley Wickham
Hi John, Here's a somewhat streamlined version of the code: Form2resfun - function(f, params) { stopifnot(inherits(f, formula), length(f) == 3) # Create function body body - substitute( crossprod(rhs - lhs), list(lhs = f[[2]], rhs = f[[3]]) ) # Create argument list free_params

Re: [Rd] Jazzing up the Task Views index page

2012-02-21 Thread Hadley Wickham
o While this is good for distributing web services, it limits the possibilities in terms of web design. In think that the CRAN maintainers do not use Javascript, for example. Did you try it without js? The jquery masonry plugin should have ok fall-back behaviour if JS is disabled. (Although

Re: [Rd] Jazzing up the Task Views index page

2012-02-21 Thread Hadley Wickham
Anyway, I did say that Task Views were rather brilliant, but were let down by their hidden position on the R web sites (tucked away as the third element of a sub-menu of a CRAN mirror site linked to by the CRAN link from the Download menu on the main R home page). The index page is rather

Re: [Rd] Using custom R_LIBS with R CMD install

2012-02-09 Thread Hadley Wickham
To clarify, system2 doesn't work in windows? It does. The system2 documentation has: On Windows, ‘env’ is currently only supported for commands such as ‘R’ and ‘make’ which accept environment variables on their command line. Yes, but R CMD INSTALL does not accept those variables in

Re: [Rd] Using custom R_LIBS with R CMD install

2012-02-08 Thread Hadley Wickham
I wonder it works that far. It won't for me on Windows nor Linux, because system2 passes the whole thing shQuoted to the shell. Hence it is highly shell dependent what happens with the ill formed command. Well I was using the env argument to system2, which claims to be cross-platform (at least

Re: [Rd] Using custom R_LIBS with R CMD install

2012-02-08 Thread Hadley Wickham
2012/2/8 Uwe Ligges lig...@statistik.tu-dortmund.de: On 08.02.2012 19:36, Hadley Wickham wrote: I wonder it works that far. It won't for me on Windows nor Linux, because system2 passes the whole thing shQuoted to the shell. Hence it is highly shell dependent what happens with the ill formed

Re: [Rd] Using custom R_LIBS with R CMD install

2012-02-08 Thread Hadley Wickham
It's hard to provide a reproducible example because it depends on exactly what package you have installed where, but I had hoped that this would at least illustrate my problem - R CMD install doesn't seem to be respecting R_LIBS.  I'm trying to understand whether this is a bug, or something I

[Rd] Using custom R_LIBS with R CMD install

2012-02-07 Thread Hadley Wickham
Hi all, Am I using the correct syntax to set a custom R_LIBS when running R CMD INSTALL from the command line? I get: R_LIBS=/Users/hadley/R-dev R CMD INSTALL aL3xa-rapport-08e68ca/ # Desktop : R_LIBS=/Users/hadley/R-dev R CMD INSTALL aL3xa-rapport-08e68ca/ # * installing to library

Re: [Rd] RFC: Proposal to make NROW() and NCOL() slightly more general

2012-02-04 Thread Hadley Wickham
On Sat, Feb 4, 2012 at 10:38 AM, Martin Maechler maech...@stat.math.ethz.ch wrote: The help has Description:   'nrow' and 'ncol' return the number of rows or columns present in 'x'.   'NCOL' and 'NROW' do the same treating a vector as 1-column matrix. and   x: a vector, array or data

Re: [Rd] Unable to reload Rdoc

2012-01-27 Thread Hadley Wickham
On Fri, Jan 27, 2012 at 3:47 AM, Mark Cowley m.cow...@garvan.org.au wrote: Dear list, I'm hoping the R guru's can help with an error i've been getting for at least a year during active package development. I have a package loaded spot a documentation bug, so I: edit the Rd file (or in the

Re: [Rd] seq_along and rep_along

2012-01-08 Thread Hadley Wickham
well put!  I would add, though, that t() generalizes to aperm(), and the magic package contains  arev()  which is a generalization of rev(). There are the flip operators of matlab, and rotating matrices/array by multiples of 90 degrees. I'm always on the lookout for other array functionality

[Rd] seq_along and rep_along

2012-01-06 Thread Hadley Wickham
Hi all, A couple of ideas for improving seq_along: * It would be really useful to have a second argument dim: seq_along(mtcars, 1) seq_along(mtcars, 2) # equivalent to seq_len(dim(mtcars)[1]) seq_len(dim(mtcars)[2]) I often find myself wanting to iterate over the rows or

Re: [Rd] seq_along and rep_along

2012-01-06 Thread Hadley Wickham
I don't see the benefit of seq_along(mtcars, 1) versus seq_len(nrow(df)) in readability. I like it because: * it reads nicely: I want a sequence along this structure in that direction * it's more consistent: for(i in seq_along(x)) - for(row in seq_along(mtcars, 1)) * it generalised in a

Re: [Rd] returning information from functions via attributes rather than return list

2012-01-04 Thread Hadley Wickham
Attributes are slightly harder to work with, so Simon's recommendation is good advice.  But in cases where you want other functions to work with the result, and the result isn't a named list with a class, then attributes are a convenient way to go. The only two snags I can think of are 1,

Re: [Rd] Subsetting a data frame vs. subsetting the columns

2011-12-28 Thread Hadley Wickham
get to the fast internal code. Cheers, S On Dec 28, 2011, at 10:37 AM, Hadley Wickham wrote: Hi all, There seems to be rather a large speed disparity in subsetting when working with a whole data frame vs. working with just columns individually: df - as.data.frame(replicate(10, runif

[Rd] Debugging namespace problems

2011-12-23 Thread Hadley Wickham
Hi all, I frequently find that I've failed to export something in my NAMESPACE and hence my package doesn't work when it's imported into another package. Does anyone have suggestion for debugging this type of problem? R CMD check passes without any ns related errors on both the importee and the

Re: [Rd] Debugging namespace problems

2011-12-23 Thread Hadley Wickham
(ggplot2) my_plot() # Plot appears. Hadley On Fri, Dec 23, 2011 at 1:50 PM, Hadley Wickham had...@rice.edu wrote: Hi all, I frequently find that I've failed to export something in my NAMESPACE and hence my package doesn't work when it's imported into another package. Does anyone have suggestion

Re: [Rd] Debugging namespace problems

2011-12-23 Thread Hadley Wickham
$S3methods[, 2], sep = .) f - ls(package:ggplot2) s3 - f[str_detect(f, fixed(.))] missing - setdiff(s3, s3e) missing[!str_detect(missing, bolus|icon)] (Code isn't reproducible, but should give you the basic idea) Hadley On Fri, Dec 23, 2011 at 1:52 PM, Hadley Wickham had...@rice.edu wrote: I

Re: [Rd] Debugging namespace problems

2011-12-23 Thread Hadley Wickham
in scales_add_defaults, where the symbol isn't found in the globalenv() when nstest is attached and ggplot2 only loaded, but is (via the search path) when ggplot2 is attached. and topenv(parent.frame()) is a replacement that gets to .GlobalEnv for ggplot2, and to the name space for nstest.

<    1   2   3   4   5   6   7   8   >