Re: [R] R vs. RStudio?

2015-01-12 Thread Hadley Wickham
On Mon, Jan 12, 2015 at 2:01 AM, peter dalgaard pda...@gmail.com wrote: On 11 Jan 2015, at 11:30 , Duncan Murdoch murdoch.dun...@gmail.com wrote: - I don't like the tiled display. I find it doesn't give me enough space. This is a mixed blessing. For teaching purposes, it helps avoid

Re: [R] R vs. RStudio?

2015-01-12 Thread Hadley Wickham
Is there a reason you don't just click the zoom button? Hadley On Mon, Jan 12, 2015 at 8:22 AM, John Fox j...@mcmaster.ca wrote: Dear Peter and Jeff, I've used RStudio in teaching for quite some time now. For displaying graphics, I open a windows() graphics device on a Windows PC or a

Re: [R] Memory hungry routines

2014-12-29 Thread Hadley Wickham
You might find the advice at http://adv-r.had.co.nz/memory.html helpful. Hadley On Tue, Dec 30, 2014 at 7:52 AM, ALBERTO VIEIRA FERREIRA MONTEIRO albm...@centroin.com.br wrote: Is there any way to detect which calls are consuming memory? I run a program whose global variables take up about 50

Re: [R] function to avoid -

2014-12-02 Thread Hadley Wickham
At the top level do: myenv - new.env(parent = emptyenv()) Then in your functions do myenv$x - 50 myenv$x etc You also should not be using data() in that way. Perhaps you want R/sysdata.rda. See http://r-pkgs.had.co.nz/data.html for more details. Hadley On Tue, Dec 2, 2014 at 2:28 AM, Karim

Re: [R] dplyr/summarize does not create a true data frame

2014-11-23 Thread Hadley Wickham
This bug is fixed in the dev version. Hadley On Sunday, November 23, 2014, John Posner john.pos...@mjbiostat.com wrote: Thanks to John Kane for an off-list consultation. As the following annotated transcript shows, it's the group_by() function that transforms a data frame into something else:

Re: [R] CMD check error

2014-11-18 Thread Hadley Wickham
Do you have a .Rbuildignore? If so, what's in it? Hadley On Tue, Nov 18, 2014 at 7:07 AM, Therneau, Terry M., Ph.D. thern...@mayo.edu wrote: I have a new package (local use only). R CMD check fails with a messge I haven't seen before, and I haven't been able to guess the cause. There are two

Re: [R] Implements XPath 2.0 in R

2014-11-18 Thread Hadley Wickham
Why do you need from xpath 2.0? It will almost certainly be easier to implement similar functionality using a little R code than adding xpath 2.0 support. Hadley On Mon, Nov 17, 2014 at 6:03 AM, Rees Morrison r...@reesmorrison.com wrote: Many users of R would like the enhanced extraction

Re: [R] Knitr: how to find out from within a .Rmd file the output type?

2014-10-31 Thread Hadley Wickham
Try knitr::opts_knit$get('rmarkdown.pandoc.to') Hadley On Fri, Oct 31, 2014 at 6:56 AM, Michal Kvasnička prgo...@gmail.com wrote: Hi. Is there a way how to find out from within a .Rmd file what output format is generated? The reason is this: I write a paper in R markdown in RStudio.

Re: [R] How to speed up list access in R?

2014-10-30 Thread Hadley Wickham
Or do all the subsetting in one pass - [ will use a hashmap. Hadley On Thu, Oct 30, 2014 at 12:05 PM, William Dunlap wdun...@tibco.com wrote: You can try using an environment instead of a list. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Oct 30, 2014 at 10:02 AM, Thomas Nyberg

Re: [R] source command inside R package scripts

2014-10-21 Thread Hadley Wickham
Your source function will be called when the package is _built_, not when it's loaded/attached. There's almost certainly a better way to solve your problem than using source() inside a package Hadley On Tue, Oct 21, 2014 at 6:24 AM, Enrico Bibbona enrico.bibb...@unito.it wrote: I have built a

Re: [R] How can I overwrite a method in R?

2014-10-09 Thread Hadley Wickham
This is usually ill-advised, but I think it's the right solution for your problem: assignInNamespace(plot.histogram, function(...) plot(1:10), graphics) hist(1:10) Haley On Thu, Oct 9, 2014 at 1:14 AM, Tim Hesterberg timhesterb...@gmail.com wrote: How can I create an improved version of a

Re: [R] Hadley's book: paper/PDF/etc. versus github

2014-10-06 Thread Hadley Wickham
the example code was missing (which defeats the convenience of having it on an ebook reader), I did not check if everything else was there or not. thanks, On Fri, Oct 3, 2014 at 6:37 AM, Hadley Wickham h.wick...@gmail.com wrote: Hi, folks. I've got a sort of coupon that would allow me to get

Re: [R] Hadley's book: paper/PDF/etc. versus github

2014-10-03 Thread Hadley Wickham
Hi, folks. I've got a sort of coupon that would allow me to get a copy of Advanced R by Hadley Wickham at no cost. OTOH, I've already cloned the github repository, and having the live Rmd files (or in this case, rmd files) is enormously more useful to me than having any form of electronic

Re: [R] R's memory limitation and Hadoop

2014-09-16 Thread Hadley Wickham
Hundreds of thousands of records usually fit into memory fine. Hadley On Tue, Sep 16, 2014 at 12:40 PM, Barry King barry.k...@qlx.com wrote: Is there a way to get around R’s memory-bound limitation by interfacing with a Hadoop database or should I look at products like SAS or JMP to work with

Re: [R] Operator proposal: %between%

2014-09-05 Thread Hadley Wickham
Please add it if you think it fits, and expand it as discussed, I am not creating a package for one single utility function. Why not? There's nothing wrong with a package that only provides one function. Hadley -- http://had.co.nz/ __

Re: [R] Detect expired RSQLiteConnection?

2014-09-02 Thread Hadley Wickham
DBI 0.3 (just released to CRAN) includes a new generic, dbIsValid(), for exactly this purpose. Unfortunately no packages implement a method for it yet, but eventually it will be the right way to detect this problem. (I'm now the maintainer for RSQLite, so I added this to my to do list:

Re: [R] URLdecode problems

2014-09-01 Thread Hadley Wickham
Hi Oliver, I think you're being misled by the default behaviour of warnings: they all get displayed at once, before control returns to the console. If you making them immediate, you get a slightly more informative error: URLdecode(0;%20@%gIL) Warning in URLdecode(0;%20@%gIL) : out-of-range

Re: [R] loading saved files with objects in same names

2014-08-23 Thread Hadley Wickham
In the future, you can avoid this problem by using saveRDS and readRDS. Hadley On Mon, Aug 18, 2014 at 7:30 PM, Jinsong Zhao jsz...@yeah.net wrote: Hi there, I have several saved data files (e.g., A.RData, B.RData and C.RData). In each file, there are some objects with same names but

Re: [R] Just stumbled across this: Advanced R programming text code - from Hadley

2014-08-11 Thread Hadley Wickham
Or just go to http://adv-r.had.co.nz/ ... Hadley On Sun, Aug 10, 2014 at 9:34 PM, John McKown john.archie.mck...@gmail.com wrote: Well, it says that it's from Hadley Wickham. https://github.com/hadley/adv-r quote This is code and text behind the Advanced R programming book. The site

Re: [R] ATTN: Urgent Guidance Needed on scraping tweets for last 10 years using TwitteR / search twitter function.

2014-07-30 Thread Hadley Wickham
The first twitter message was sent on March 21st, 2006... Hadley On Wed, Jul 30, 2014 at 3:58 AM, Abhishek Dutta abhishek@gmail.com wrote: Hi This is Abhishek and I am trying to look for tweets on 'Election' from 2000 to YTD. I have registered on twitter and performed a handshake

Re: [R] String comparison, trailing blanks make a difference.

2014-07-19 Thread Hadley Wickham
If you have unicode strings, you may need to do even more because there are often multiple ways of representing the same glyph. I made a little demo at http://rpubs.com/hadley/unicode-normalisation, since any unicode characters are likely to get mangled by email. Hadley On Fri, Jul 18, 2014 at

Re: [R] list of valid R encodings.in source(...,encoding=)

2014-07-11 Thread Hadley Wickham
It's documented in the Encodings section of ?file: As from R 3.0.0 the encoding UTF-8-BOM is accepted for reading and will remove a Byte Order Mark if present (which it often is for files and webpages generated by Microsoft applications). If it is required (it is not recommended) when writing it

Re: [R] Best practice: to factor or not to factor for float variables

2014-07-04 Thread Hadley Wickham
analysis techniques. In my particular case, I have measurements of several variables at several, sometimes equal, heights. Following the tidy data approach of Hadley Wickham, I want to put all data in one data frame. In principle, the height variable is something like a category. For example, I

Re: [R] Rscript fails where Rterm works

2014-06-12 Thread Hadley Wickham
Explicitly load the methods package: library(methods) Hadley On Thu, Jun 12, 2014 at 2:22 PM, Bond, Stephen stephen.b...@cibc.com wrote: I have a script which loads library(XLConnect) wb - loadWorkbook(wbname) the code works without errors when run from ESS which uses R version 3.0.1

Re: [R] Documenting docType data

2014-05-20 Thread Hadley Wickham
Don't export the dataset? (as mentioned in the answer to that question). If that doesn't help, please supply a minimal reproducible example. Hadley On Tue, May 20, 2014 at 3:35 AM, Witold E Wolski wewol...@gmail.com wrote: Hi, I am Trying to document data using roxygen2 by following the

Re: [R] as.character(quote(x$y) ) = $ x y not x$y?

2014-05-09 Thread Hadley Wickham
Beware of the is.* functions: * is.object() does not test the usual definition of objects * is.vector() does not test the usual definition of vectors * is.numeric() does not work the same way as is.character() or is.integer() * is.Date() doesn't exist * is.nan() doesn't return TRUE for some NaNs

Re: [R] get element of list with default?

2014-04-15 Thread Hadley Wickham
You really want to use the names of the list since lists can contain null. I'd recommend something more like: getElement - function(x, i, default) { if (i %in% names(x)) return(x[[i]]) default } Hadley On Tue, Apr 15, 2014 at 10:53 AM, Spencer Graves spencer.gra...@structuremonitoring.com

Re: [R] Growth of CRAN?

2014-04-14 Thread Hadley Wickham
For finer level detail, have a look at https://github.com/hadley/cran-packages. It contains the description file of every package ever uploaded to CRAN (the cache is a few months out of date, but you can easily re-run) Hadley On Sun, Apr 13, 2014 at 12:59 PM, Spencer Graves

Re: [R] Growth of CRAN?

2014-04-14 Thread Hadley Wickham
Yes, because it has every version of every DESCRIPTION. Hadley On Mon, Apr 14, 2014 at 11:13 AM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hi, Hadley: On 4/14/2014 5:53 AM, Hadley Wickham wrote: For finer level detail, have a look at https://github.com/hadley/cran

Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Hadley Wickham
Even if you do get Rstudio running on a server, unfortunately it won't help. The ipad doesn't support quite enough html to get a fully functional Rstudio interface - almost everything works but you can't type anything :/ It would be possible to fix this, but fundamentally we don't believe that

Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Hadley Wickham
) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Hadley Wickham h.wick...@gmail.com 4/11/2014 6:01 PM Even if you do get Rstudio running on a server, unfortunately it won't help. The ipad doesn't support quite enough html to get a fully functional Rstudio

Re: [R] getting arg names in function calls?

2014-04-08 Thread Hadley Wickham
You might find it helpful to read http://adv-r.had.co.nz/Expressions.html, and look at pryr:: standardise_call(). Hadley On Tue, Apr 8, 2014 at 6:52 PM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hi, Bill: Thanks for the reply. Unfortunately, I don't see how that

Re: [R] Environment variable defined in .bashrc is not recognized by R

2014-04-01 Thread Hadley Wickham
Use .Renviron Hadley On Tue, Apr 1, 2014 at 2:33 AM, Luca Cerone luca.cer...@gmail.com wrote: Thanks, effectively I was using RStudio (on an Ubuntu 12.04 machine). Is there any other way to make the variable available to Rstudio? Now I have simply written the path manually, but I like the

Re: [R] using data.table ,plyr

2014-03-27 Thread Hadley Wickham
It's rude to ask a question both on r-help and on stackoverflow (http://stackoverflow.com/questions/22685896), because people might spend their time answering your question when it's already been answered elsewhere. Hadley On Thu, Mar 27, 2014 at 6:01 AM, Rohit Gupta rhtgpt...@gmail.com wrote:

Re: [R] Syntax for order()

2014-03-25 Thread Hadley Wickham
If you want to continue to be spoiled, try: library(dplyr) arrange(dat1, val) Hadley On Tue, Mar 25, 2014 at 2:20 PM, John Kane jrkrid...@inbox.com wrote: Thank. Once I got Sarah's email I realised I should have been usling with(). Hadley's ggplot syntax has spoiled/confused me. John

Re: [R] Survfit error

2014-03-07 Thread Hadley Wickham
On Fri, Mar 7, 2014 at 6:46 AM, Therneau, Terry M., Ph.D. thern...@mayo.edu wrote: The help page for the survfit function says it expects a formula as its first argument so try: sleepfit - survfit(Surv(timeb, death)~1, data = sleep) David Sent from my iPhone ... so unable to test. This

Re: [R] CRAN policies - citing others

2014-02-20 Thread Hadley Wickham
I believe this is what you should do: * In the lbfgsb.cpp from base R, include the GPL blurb and R copyright holders. Also add your own names. (see e.g. https://github.com/hadley/pryr/blob/master/src/typename.cpp) * In the DESCRIPTION, add the R core team as a contributor,

Re: [R] Change data format query

2014-02-19 Thread Hadley Wickham
You might want to try reading http://vita.had.co.nz/papers/tidy-data.html, which lays out the principles by which you might want to organise your data, matching each task with the appropriate reshape2 function. Hadley On Wed, Feb 19, 2014 at 9:18 AM, drruddy gmail drmarkru...@gmail.com wrote:

Re: [R] Packages Depending on my package

2014-02-06 Thread Hadley Wickham
Is there a way to determine which, if any, CRAN packages depend on my CRAN package, mondate? devtools::revdep(mondate) [1] zoo If you want to contact the maintainers: devtools::revdep_maintainers(mondate) [1] Achim Zeileis achim.zeil...@r-project.org If you want all recursive

Re: [R] Problem connecting to database via RPostgreSQL/RS-DBI: could not connect error

2014-02-03 Thread Hadley Wickham
On Fri, Jan 31, 2014 at 9:40 PM, andrewH ahoer...@rprogress.org wrote: In the description section of the RPostgreSQL package documentation, it states: In order to build and install this package from source, PostgreSQL itself must be present your system to provide PostgreSQL functionality via

Re: [R] Understanding namespace for plyr / dplyr

2014-01-29 Thread Hadley Wickham
If you load plyr first, then dplyr, I think everything should work. dplyr::summarise works similarly enough to plyr::summarise that it shouldn't cause problems. Hadley On Wed, Jan 29, 2014 at 4:19 PM, Trevor Davies davies.tre...@gmail.com wrote: I think I have a hole in my understanding of how

Re: [R] Type III tests and Cox models

2014-01-20 Thread Hadley Wickham
To save others a little hunting, you can read the vignette online at http://cran.r-project.org/web/packages/survival/vignettes/tests.pdf Hadley On Mon, Jan 20, 2014 at 11:47 AM, Terry Therneau thern...@mayo.edu wrote: Someone asked a question about this on the list a couple months ago. I

Re: [R] Find the package of a class given classname

2014-01-13 Thread Hadley Wickham
How to find the package of a class given classname? For example, there is a class called GAlignments, I want to do something like attr(GAlignments, package) that gives you the package where the class is defined? But of course, attr(GAlignments, package) won't work... You didn't say whether

Re: [R] recoding table dimensions interactively

2014-01-09 Thread Hadley Wickham
Hi Michael, It's pretty easy with reshape: library(reshape2) ucbm - melt(UCBAdmissions) acast(ucbm, Admit + Gender ~ Dept) acast(ucbm, Admit ~ Dept + Gender) acast(ucbm, Admit + Dept + Gender ~ .) # You can also do aggregations acast(ucbm, Admit ~ Dept, fun = sum) Hadley On Thu, Jan 9, 2014

[R] The R Journal, Volume 5, Issue 2

2014-01-07 Thread Hadley Wickham
Dear all, The latest issue of The R Journal is now available at http://journal.r-project.org/archive/2013-2/ Many thanks to all contributors. Hadley -- Editor-in-chief, The R Journal ___ r-annou...@r-project.org mailing list

Re: [R] RSQLite: Tracking an error message to its source

2014-01-05 Thread Hadley Wickham
Can you, or anyone, give me any hint on where -- no, not where, _how_ -- to find the code for any of the functions called between dbGetQuery method for conn=SQLiteConnection, or for any of the functions that are called by the dbGetQuery method for SQLite connections that are in the chain that

Re: [R] RSQLite: Tracking an error message to its source

2014-01-05 Thread Hadley Wickham
Though I admit that it bothers me that, although the SQLite syntax documentation for CREATE INDEX, here: http://www.sqlite.org/lang_createindex.html does say the database name is optional, it also says that, if you include it, the period the period between the db name and the table name is

Re: [R] Package dependencies in building R packages

2013-12-31 Thread Hadley Wickham
Thanks for your kind response Duncan. To be more specific, I'm using the function mvrnorm from MASS. The issue is that MASS depends on survival and I have a function in my package named tt() which conflicts with a function in survival of the same name. I can think of 2 alternatives solutions

Re: [R] gc() vs memory.profile()

2013-12-27 Thread Hadley Wickham
Hi Ross, It's not obvious how useful memory.profile() is here. I created the following little experiment to help me understand what memory.profile() is showing (and to make it easier to see the changes), but it's left me more confused than enlightened: m_delta - function(expr) { # Evaluate in

Re: [R] roxygen2 and install.packages()

2013-12-09 Thread Hadley Wickham
Unfortunately roxygen2 3.0.0 now requires R 3.0.2. See https://github.com/klutometis/roxygen/issues/163 for some discussion as to why. Hadley On Mon, Dec 9, 2013 at 12:28 PM, François Lefebvre lefeb...@gmail.com wrote: Hi, I am unable to install roxygen2 on R3.0.2. Any idea why?

Re: [R] ifelse -does it manage the indexing?

2013-12-03 Thread Hadley Wickham
A better solution to this problem is to use character indexing: x - c(Tuesday, Thursday, Sunday) c(Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7)[x] http://adv-r.had.co.nz/Subsetting.html#lookup-tables-character-subsetting Hadley On Mon, Dec 2, 2013

Re: [R] Should there be an R-beginners list?

2013-11-25 Thread Hadley Wickham
I do not see how it can be illegal to download and duplicate the posts, since all the content is licensed under CC BY-SA. I might have missed something there: http://stackexchange.com/legal If that is really the case, I think I will have to reconsider if I should use it any more. I'm not a

Re: [R] Should there be an R-beginners list?

2013-11-25 Thread Hadley Wickham
Here's a similar plot for stackoverflow: http://data.stackexchange.com/stackoverflow/query/150130/r-questions-and-answers-per-year#graph and one broken down by month http://data.stackexchange.com/stackoverflow/query/150129/r-questions-and-answers-per-month#graph Hadley On Mon, Nov 25, 2013 at

Re: [R] Should there be an R-beginners list?

2013-11-25 Thread Hadley Wickham
Oops, I misunderstood the database schema, and that only includes _questions_ tagged R, not the corresponding answers. Hadley On Mon, Nov 25, 2013 at 9:55 AM, Hadley Wickham h.wick...@gmail.com wrote: Here's a similar plot for stackoverflow: http://data.stackexchange.com/stackoverflow/query

Re: [R] Functional Programming patterns

2013-11-20 Thread Hadley Wickham
I have some notes on functional programming in R at http://adv-r.had.co.nz/. Hadley On Wed, Nov 20, 2013 at 3:02 AM, mohan.radhakrish...@polarisft.com wrote: Hi, ' Not specific to 'R'. I search for patterns and found http://patternsinfp.wordpress.com/ which is too heavy for me. There is a

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-09 Thread Hadley Wickham
Modelling a mutable entity, i.e. an account, is really a perfect example of when to use reference classes. You might find the examples on http://adv-r.had.co.nz/OO-essentials.html give you a better feel for the strengths and weaknesses of R's different OO systems. Hadley On Sat, Nov 9, 2013 at

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Hadley Wickham
There's little practical difference; both hover from 0.00 to 0.03 s system time. I could barely tell the difference even averaged over 100 runs; I was getting an average around 0.007 (system time) and 2.5s user time for both methods. It's almost always better to use a high precision timer,

Re: [R] microbenchmark

2013-09-17 Thread Hadley Wickham
I'm not sure why either, but here's a simpler (and much faster) illustration of the problem: library(microbenchmark) A - matrix(1:9,3) replicate(10, microbenchmark(colMeans(A), times = 4)$time) replicate(10, microbenchmark(A, times = 4)$time) Hadley On Mon, Sep 16, 2013 at 8:11 AM, Christophe

Re: [R] Should I wrap more package examples in \dontrun{} ?

2013-09-03 Thread Hadley Wickham
As a user of your package, I would find it irritating if example(foo) didn't run anything. It would be more irritating (and would indicate sloppiness on your part) if the examples failed when I cut and pasted them. These both suggest leaving the examples running. As the author of your

Re: [R] R CMD check Note: Non-standard file found at top level

2013-09-03 Thread Hadley Wickham
The note is telling you that you usually shouldn't have a file called build in the top level of your package. What's in the file and why is it there? Hadley On Tue, Sep 3, 2013 at 10:01 AM, S Subramanian ssubraman...@sssihl.edu.in wrote: My R CMD check pkgname and R CMD build pkgname run

Re: [R] Should I wrap more package examples in \dontrun{} ?

2013-09-03 Thread Hadley Wickham
It was my understanding that package authors are responsible for not breaking other CRAN packages without warning. For example, before I release a new version of plyr or ggplot2, I run R CMD check on every package that depends on my package. I then let the maintainers know if something is

Re: [R] new.env() and attach for write?

2013-08-28 Thread Hadley Wickham
On Wed, Aug 28, 2013 at 4:32 PM, ivo welch ivo.we...@anderson.ucla.edu wrote: is it possible to temporarily change the destination environment where objects are written to? I am thinking a - new.env() attach(a) ### run some code, such as... b - function(x) x detach(a) a$b

Re: [R] the inverse of assign()

2013-08-27 Thread Hadley Wickham
It's not really the inverse of assign (that's get), but I think you want substitute. See http://adv-r.had.co.nz/Computing-on-the-language.html for more details. Hadley On Tue, Aug 27, 2013 at 4:13 PM, Robert Lynch robert.b.ly...@gmail.com wrote: I am looking for a way to extract the name of a

Re: [R] RCurl cookiejar

2013-08-25 Thread Hadley Wickham
Hi Earl, Have you read the libCurl documentation for CURLOPT_COOKIEJAR? : Pass a file name as char *, zero terminated. This will make libcurl write all internally known cookies to the specified file when curl_easy_cleanup(3)is called. If no cookies are known, no file will be created. Specify -

Re: [R] Appropriateness of R functions for multicore

2013-08-20 Thread Hadley Wickham
For tasks which don't involve I/O but fail with mclapply, how does one work out where the problem is? The handy browser() function which allows for interactive diagnosis won't work with parallel jobs. What other approaches can one use? ?dump.frames - interactive debugging after the fact.

Re: [R] Understanding S4 method dispatch

2013-08-14 Thread Hadley Wickham
In my opinion the reason for the behavior lies in the specific multiple inheritance structure between AB, B and A. So what if we don't make such a weird inheritance structure, and instead have A and B inherit from a common parent: setClass(A, contains = list) setClass(B, contains = list)

Re: [R] Understanding S4 method dispatch

2013-08-14 Thread Hadley Wickham
On Wed, Aug 14, 2013 at 11:36 AM, Simon Zehnder szehn...@uni-bonn.de wrote: Because the signature is always (A,A) or (B,B). Then, as in AB we have A and B and no relationship between A and B, R chooses the method lexicographically. The result is as expected: f for A is chosen. It's not as

[R] Understanding S4 method dispatch

2013-08-13 Thread Hadley Wickham
Hi all, Any insight into the code below would be appreciated - I don't understand why two methods which I think should have equal distance from the call don't. Thanks! Hadley # Create simple class hierarchy setClass(A, NULL) setClass(B, A) a - new(A) b - new(B) setGeneric(f, function(x, y)

Re: [R] Understanding S4 method dispatch

2013-08-13 Thread Hadley Wickham
The class AB inherits from A and from B, but B already inherits from class A. So actually you only have an object of class B in your object of class AB. When you call the function f R looks for a method f for AB objects. It does not find such a method and looks for a method of the object

[R] The R Journal, Volume 5, Issue 1

2013-07-03 Thread Hadley Wickham
Dear all, The latest issue of The R Journal is now available at http://journal.r-project.org/archive/2013-1/ Many thanks to all contributors. Hadley -- Editor-in-chief, The R Journal ___ r-annou...@r-project.org mailing list

Re: [R] Lexical scoping is not what I expect

2013-06-27 Thread Hadley Wickham
I too find R's lexical scoping rules straightforward. However, I'd say that if your code relies on lexical scoping to find something, you should probably rewrite your code. Except of course that almost every function relies on lexical scoping to some extent! Do you want: f - function(a, b)

Re: [R] Need help to building R package with devtools

2013-05-14 Thread Hadley Wickham
Can someone help what I need to do to make 'devtools' work? A quick asking around indicates that Rtools 3.0 should work fine for 2.15.3 maintenance. Thus, the issue is probably a purely formal bug in devtools's version comparison logic, and you need to pester its maintainer. Unless it has

Re: [R] identify object that causes Error in loadNamespace(name) : there is no package called ‘R.utils’

2013-04-24 Thread Hadley Wickham
I must admit that I'm a bit surprised by this. I was always under the impression that saving/restoring workspaces was the proper workflow in R. If you use R interactively (e.g., not by running scripts), how else would you store your data, intermediary results, etc., while working on a

Re: [R] NAMESPACE and imports

2013-04-19 Thread Hadley Wickham
Hi Frank, The problem is you can't lump together multiple S3 methods. Instead of: S3method(latex, anova.rms, bj, cph, Glm, Gls, lrm, naprint.delete, ols, pphsm, psm, rms, Rq, summary.rms, validate) You need S3method(latex, anova.rms) S3method(latex, bj) S3method(latex, cph) etc. Hadley

[R] 10% off Intro R training from RStudio: NYC May 13-14, SF May 20-21

2013-04-16 Thread Hadley Wickham
Hi all, At RStudio, we're hosting our Introduction to R Workshop this May in two locations. As an R-help subscriber, we're offering 10% off! * Intro to data science with R (http://goo.gl/bplg3) May 13-14 New York City * Intro to data science with R (http://goo.gl/VCUFL) May 20-21 San

Re: [R] 10% off Intro R training from RStudio: NYC May 13-14, SF May 20-21

2013-04-16 Thread Hadley Wickham
typos. On Apr 16, 2013, at 8:09 AM, Hadley Wickham h.wick...@gmail.com wrote: Hi all, At RStudio, we're hosting our Introduction to R Workshop this May in two locations. As an R-help subscriber, we're offering 10% off! * Intro to data science with R (http://goo.gl/bplg3) May 13-14 New York

Re: [R] Stringr Package

2013-04-10 Thread Hadley Wickham
with(dat, data.frame(X=rep(X, each=2), Y=unlist(strsplit(Y, split= - str_split_fixed would be a bit safer here. Hadley -- Chief Scientist, RStudio http://had.co.nz/ __ R-help@r-project.org mailing list

Re: [R] quotes in cat() within function

2013-04-09 Thread Hadley Wickham
On Tue, Apr 9, 2013 at 3:06 AM, Daniel Caro dca...@gmail.com wrote: Hello all, Sorry if this question has been answered in the past, but I could not find an answer. I am trying to print quotes within a cat output. The arguments are: file= Data labels directory= /home/mylaptop/ The

Re: [R] categorized complete list of R commands?

2013-04-04 Thread Hadley Wickham
Here's a categorisation of all the functions in base and utils that I made recently (not sure if the csv will survive posting the list). Feedback welcomed - this was just a quick first pass, and it's not authoritative. Hadley On Thu, Apr 4, 2013 at 12:34 AM, ivo welch ivo.we...@anderson.ucla.edu

Re: [R] ls() with different defaults: Solution;

2013-03-12 Thread Hadley Wickham
On Tue, Mar 12, 2013 at 12:59 PM, Szumiloski, John john_szumilo...@merck.com wrote: Dear useRs, Some time ago I queried the list as to an efficient way of building a function which acts as ls() but with a different default for all.names:

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-15 Thread Hadley Wickham
This is unfortunately reinforced by the (Not So) Short Introduction to S4 Object Oriented Programming in R - I wouldn't recommend that document to learn about S4. The most important thing to get about OO in R is that methods belong to generic functions, not like classes, as in most other

Re: [R] First R Package --- Advice?

2013-02-06 Thread Hadley Wickham
Other people have recommended Roxygen, but honestly I haven't seen a package documented with Roxygen where the documentation was adequate. It looks as though it's great to get initial documentation created, but does not appear to encourage followup. I don't think that's a problem with roxygen

Re: [R] First R Package --- Advice?

2013-02-06 Thread Hadley Wickham
I have heard of people using noweb to do this, but I can't point to any examples. I'd actually recommend against it. Good documentation files don't make good source files. the compiler package in base R is, apparently, developed using noweb

Re: [R] function coverage

2013-01-14 Thread Hadley Wickham
I think codetools could do this reasonably well with the walkCode function, but I've never done it so I don't have sample code, and walkCode is mostly an internal function. There are a couple of approaches here: http://stackoverflow.com/questions/14276728/ Hadley -- Chief Scientist, RStudio

Re: [R] Merging list of dataframes with reshape merge_all

2013-01-11 Thread Hadley Wickham
PS: Just a related side-question: Why is merge_all not included in the newer package reshape2 as this is considered to be a reboot of the reshape package? Because it doesn't work very well, as you've discovered. There's an equivalent join_all in plyr. Hadley -- Chief Scientist, RStudio

Re: [R] ggplot2: varwidth-equivalent for geom_boxplot?

2012-11-18 Thread Hadley Wickham
I'd like to resurrect this issue: is the varwidth equivalent (boxplot box-width scaling according to number of data points) emulatable in the 0.9.* versions of ggplot2? Width still doesn't seem capable of accepting a vector with length 1 ... No, and it's not currently on the to do list.

Re: [R] devtools - document() weiredness

2012-11-14 Thread Hadley Wickham
I know this scenario is strange as there's no roxygenizable stuff in the package, but I am trying to track down an identical error in one of my nascent packages and am wondering 1) where this behavior originates and 2) why document() does not provide more informative feedback. See

Re: [R] A general question: Is language S a component part of R?

2012-11-05 Thread Hadley Wickham
On Monday, November 5, 2012, Rolf Turner wrote: On 06/11/12 09:40, Iurie Malai wrote: So, R (as a language) can be viewed as an extended S language (S + some improvements)? And the R environment includes this (extended) language + extensions? Are others getting as sick of this silly,

Re: [R] print and execute functions in a package namespace

2012-10-30 Thread Hadley Wickham
But I need to work with the names of the figure functions instead, something like figlist - paste0(fig, 1:3) Are the functions exported or internal? # Use for internal functions pkg - asNamespace(mypackage) # Use for exported functions: pkg - package:mypackage # Find functions matching a

Re: [R] Regarding licensing Terms

2012-10-03 Thread Hadley Wickham
Most critical issues vis-a-vis open source licenses come into play when you cross the line from simply being a user/developer to copying and distributing. In the latter case, whether you plan to charge for the resultant product or make it available for free, is irrelevant. I think the main

Re: [R] Basic question about: - and method start with dot.

2012-10-02 Thread Hadley Wickham
What is the special meaning for the method name start with a dot? It means nothing in particular, except that such objects don't show up in ls() by default. The _intention_ is usually that the function is only to be used internally and not for end-user use. But these days, if you're

Re: [R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-27 Thread Hadley Wickham
where myProject is a package containing all the scripts, written as functions. Yes, the eventual fate of these functions is expected to be a package. I'd like the pushed/pulled code to be runable as is without an intermediate step of package creation or gsub()ing hardcoded paths. You might

Re: [R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-27 Thread Hadley Wickham
I'd like to have the code source files from the 'local' git repository without modification, where 'local' could mean c:\yada\ for one person, m:\my documents\wetlands\ for another, and l:\foo\bar\sharedRemote\wet\ to another user. ... Yes. Use library(myProject) where myProject

Re: [R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-27 Thread Hadley Wickham
I would usually do more than that: I find the R documentation system helpful even when I'm the only user of a package (and there are the prompt* functions for quickly creating it, as well as package.skeleton to set things up at the beginning). Vignettes are a great way to organize and

Re: [R] New Submission to CRAN note

2012-09-22 Thread Hadley Wickham
After uploading your package via ftp, in your email to c...@r-project.org you need to state that you agree to the CRAN repository policy (http://cran.r-project.org/web/packages/policies.html) Hadley On Sat, Sep 22, 2012 at 1:02 AM, Christopher Desjardins cddesjard...@gmail.com wrote: Hi, I

Re: [R] qplot: plotting precipitation data

2012-09-20 Thread Hadley Wickham
= levels) ggplot(mydata, aes(x = start)) + geom_rect(aes(xmin = start, xmax = end, ymin = 0, ymax = peak)) + xlim(as.character(levels)) On Sun, Sep 16, 2012 at 11:11 AM, Rui Barradas ruipbarra...@sapo.pt wrote: Maybe a bug in ggplot2::geom_rect? I'm Cceing this to Hadley Wickham, maybe he

Re: [R] multi-column factor

2012-09-17 Thread Hadley Wickham
If you have a million levels is it really necessary to use a factor? I'm not sure what advantages it will to have to a string in this circumstance (especially since you don't seem to know the levels a priori but have to learn them from the data). Hadley On Sunday, September 16, 2012, Sam

Re: [R] ggplot2: legend for geom_rug() ..?

2012-08-15 Thread Hadley Wickham
On Thu, Jun 7, 2012 at 9:30 AM, Tim Smith tim_smith_...@yahoo.com wrote: Hi, Here is the corrected code: library(ggplot2) ids - paste('id_',1:3,sep='') before - sample(9) after - sample(1:10,9) dat - as.matrix(cbind(before,after)) rownames(dat) - rep(ids,3) position -

Re: [R] Recursive function calls

2012-08-03 Thread Hadley Wickham
On Fri, Aug 3, 2012 at 12:19 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, This seems to work. trim2 - function(x) { if(is.atomic(x)) gsub(^[[:space:]]+|[[:space:]]+$, , x) else sapply(x, function(y) trim2(y)) } Using sapply is a bit dangerous here.

Re: [R] Recursive function calls

2012-08-03 Thread Hadley Wickham
It's nice that R keeps the base function list short enough that you can look at it, but it would be nice to have a few more convenience functions included, especially ones that mirror common functions, like trim sum(sapply(search(), function(x) length(ls(x [1] 2376 Over two thousand

<    1   2   3   4   5   6   7   8   9   10   >