Re: [R] how to get paste() to output \% so LaTeX will interpret it as a percent sign rather than a comment symbol

2023-09-08 Thread Hadley Wickham
You're getting confused between the contents of the string and the printed representation of the string. There's a little bit about this in R4DS: https://r4ds.hadley.nz/strings#escapes (or in brief, do writeLines(trailing.7.message)) Hadley On Fri, Sep 8, 2023 at 7:23 AM Christopher Ryan via

Re: [R] Book Recommendation

2023-08-28 Thread Hadley Wickham
These days I'd recommend duckdb (https://cran.r-project.org/web/packages/duckdb/index.html) instead. It's a similar design to RSQLite (i.e. you don't need a separate server) but it's designed for the needs of data science. Hadley On Tue, Aug 29, 2023 at 9:22 AM Martin Møller Skarbiniks Pedersen

Re: [R] Book Recommendation

2023-08-28 Thread Hadley Wickham
You might find this chapter of R for Data Science helpful: https://r4ds.hadley.nz/databases Hadley On Tue, Aug 29, 2023 at 3:47 AM Stephen H. Dawson, DSL via R-help wrote: > > Good Morning, > > > I am doing some research to develop a new course where I teach. I am > looking for a book to use in

Re: [R] Merge with closest (not equal) time stamps

2023-08-09 Thread Hadley Wickham
It sounds like you might want a rolling join, e.g. https://dplyr.tidyverse.org/reference/join_by.html#rolling-joins. (And data.table has similar functionality which inspired dplyr) Hadley On Mon, Aug 7, 2023 at 9:32 PM Naresh Gurbuxani wrote: > > > I have two dataframes, each with a column for

Re: [R] Off-topic: ChatGPT Code Interpreter

2023-07-18 Thread Hadley Wickham
> I am not sure what your example means but text to image conversion can be > done quite easily in many programming environments and does not need an AI > unless you are using it to hunt for info. I mean you can open up many Paint > or Photo programs and look at the menus and often one allows you

Re: [R] R does not run under latest RStudio

2023-04-07 Thread Hadley Wickham
I'm not aware of widespread problems, but it's possible that some combination of OS, RStudio version, and R version might be causing problems. Unfortunately I don't think there's enough information in this thread for anyone to tell if that's the case. Hadley On Fri, Apr 7, 2023 at 1:18 PM

Re: [R] Lazy-load corrupt?

2023-02-04 Thread Hadley Wickham
This often indicates you need to restart R. Hadley On Friday, February 3, 2023, Nick Wray wrote: > Hello When trying to call various packages eg > library(raster) > library(sp) > library(rgdal) > > I get this error message: > Loading required package: sp > Error: package or namespace load

Re: [R] interval between specific characters in a string...

2022-12-04 Thread Hadley Wickham
On Sun, Dec 4, 2022 at 1:22 PM wrote: > > This may be a fairly dumb and often asked question about some functions like > strsplit() that return a list of things, often a list of ONE thing that be > another list or a vector and needs to be made into something simpler.. > > The examples shown

Re: [R] interval between specific characters in a string...

2022-12-04 Thread Hadley Wickham
On Sun, Dec 4, 2022 at 12:50 PM Hervé Pagès wrote: > > On 03/12/2022 07:21, Bert Gunter wrote: > > Perhaps it is worth pointing out that looping constructs like lapply() can > > be avoided and the procedure vectorized by mimicking Martin Morgan's > > solution: > > > > ## s is the string to be

Re: [R] help finding a starting point to diagnose inability to install or update packages

2021-04-25 Thread Hadley Wickham
If this happens again in the future, you might try the development version of pak: install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/;) pak::pak("tidyverse") pak automatically diagnoses a number of common problems that causes install.packages() to fail. Hadley On Sun, Apr 25,

Re: [R] roxygen2 & markdown & math

2021-01-14 Thread Hadley Wickham
On Tuesday, January 12, 2021, Duncan Murdoch wrote: > On 12/01/2021 1:12 p.m., Sigbert Klinke wrote: > >> Hi, >> >> thanks a lot, but maybe I was to vague. >> >> I do not want to replace \eqn{...} and \deqn{...} by \mjseqn{...} and >> \mjsdeqn{...}. I would like to use $...$ and $$...$$ as in

Re: [R] How to understand the mentality behind tidyverse and ggplot2?

2020-11-18 Thread Hadley Wickham
I'd recommend two places to get started: * https://r4ds.had.co.nz/data-visualisation.html for a quick intro to ggplot2 (and the rest of the book explains the general tidyverse philosophy) * https://ggplot2-book.org for the full details of ggplot2. Hadley On Wed, Nov 18, 2020 at 11:37 AM C W

Re: [R] combine filter() and select()

2020-08-20 Thread Hadley Wickham
On Wed, Aug 19, 2020 at 10:03 AM Ivan Calandra wrote: > > Dear useRs, > > I'm new to the tidyverse world and I need some help on basic things. > > I have the following tibble: > mytbl <- structure(list(files = c("a", "b", "c", "d", "e", "f"), prop = > 1:6), row.names = c(NA, -6L), class =

Re: [R] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Hadley Wickham
> | but they won't receive any new > | features, and we believe that there > | are now better approaches to solving > | the same problem. > > Is tidyr::pivot_longer this better > solution? It is an easier to understand > version of the now retired and confusing > (for me) tidyr::gather which at

Re: [R] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Hadley Wickham
we believe that there are now better approaches to solving the same problem. Hadley On Mon, Aug 17, 2020 at 3:58 AM Eric Berger wrote: > > Thanks for this information Thierry. I was not aware. > The author of the packages is Hadley Wickham. He writes on Github that he > does plan to

Re: [R] A better scales::dollar() ?

2019-12-09 Thread Hadley Wickham
You can get pretty close with label_number_si(): pounds <- scales::label_number_si(prefix = "£") pounds(10 ^ (0:7)) #> [1] "£1""£10" "£100" "£1K" "£10K" "£100K" "£1M" "£10M" Created on 2019-12-09 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001) Hadley On Fri, Dec

Re: [R] Supplying names to vars() in ggplot2.

2019-11-17 Thread Hadley Wickham
See this new vignette in dev ggplot2: https://ggplot2.tidyverse.org/dev/articles/ggplot2-in-packages.html Hadley On Saturday, November 16, 2019, Rolf Turner wrote: > > I need to call ggplot() from another function with the names of the > faceting variables supplied as arguments to the calling

Re: [R] Why I can not get work the "tidyverse" and "corrr" libraries

2019-04-17 Thread Hadley Wickham
On Wed, Apr 17, 2019 at 1:06 PM Jeff Newmiller wrote: > > From reading > > > namespace ‘rlang’ 0.3.0 is already loaded, but >= 0.3.1 is required > > it would seem that you need to upgrade your rlang package... Typically this indicates you need to restart R. Hadley -- http://hadley.nz

Re: [R] Unable to install ggplot2

2019-03-06 Thread Hadley Wickham
rlang works with R 3.1 and up, but it does require compilation from source, which I suspect is the root cause of this problem. Hadley On Wed, Mar 6, 2019 at 5:36 PM peter dalgaard wrote: > > Also, R seems to be version 3.2.x i.e. 3-4 years old. Earliest rlang is anno > 2017 as far as I can

Re: [R] RMarkdown vignettes v. Jupyter notebooks?

2018-10-11 Thread Hadley Wickham
I'd highly recommend Yihui's extensive write up: https://yihui.name/en/2018/09/notebook-war/ Hadley On Thu, Oct 11, 2018 at 4:08 AM Spencer Graves wrote: > > Hello: > > >What are the differences between Jupyter notebooks and RMarkdown > vignettes? > > >I'm trying to do real time

Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Hadley Wickham
You need to recursively walk the parse tree/AST. See, e.g., https://adv-r.hadley.nz/expressions.html#ast-funs Hadley On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke wrote: > Hi, > > I have read an R program with > > expr <- parse("myRprg.R") > > How can I extract the parameters of a specifc R

Re: [R] Converting a list to a data frame

2018-05-03 Thread Hadley Wickham
On Wed, May 2, 2018 at 11:53 AM, Jeff Newmiller wrote: > Another approach: > > > library(tidyr) > L <- list( A = data.frame( x=1:2, y=3:4 ) > , B = data.frame( x=5:6, y=7:8 ) > ) > D <- data.frame( Type = names( L ) >,

Re: [R] Problem installing libxml2 under Homebrew

2018-02-17 Thread Hadley Wickham
Is there a reason that you can't use the binary provided by CRAN? That's the easiest way to get xml2. Hadley On Sat, Feb 17, 2018 at 1:53 AM, Peter Meilstrup wrote: > i am trying to install xml2 from CRAN, and it is throwing an error > that it cannot find the libxml2

Re: [R] Fwd: Wanted to learn R Language

2017-11-30 Thread Hadley Wickham
Or try haven::read_xpt(): http://haven.tidyverse.org/reference/read_xpt.html Hadley On Thu, Nov 30, 2017 at 3:13 PM, Jim Lemon wrote: > Hi SAS_learner, > Have a look at the read.xport function in the foreign package. > > Jim > > On Fri, Dec 1, 2017 at 7:50 AM, SAS_learner

Re: [R] To implement OO or not in R package, and if so, how to structure it?

2017-09-14 Thread Hadley Wickham
> Did you read this? > https://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf > > Maybe it could give you some insight in how to create package. That resource is ~9 years old. There are more modern treatments available. You can read mine at http://r-pkgs.had.co.nz. Hadley --

Re: [R] To implement OO or not in R package, and if so, how to structure it?

2017-09-14 Thread Hadley Wickham
I just finished the first draft of the chapters on OO programming for the 2nd edition of "Advanced R": https://adv-r.hadley.nz - you might find them helpful. Hadley On Thu, Sep 14, 2017 at 7:58 AM, Alexander Shenkin wrote: > Hello all, > > I am trying to decide how to

Re: [R] functions from 'base' package are not accessible

2017-08-24 Thread Hadley Wickham
This was a change in tidyr 0.7.0 that is causing a lot of confusion, so we are preparing tidyr 0.7.1 which will back this change out. If you want a work around in the meantime, you can express your operation a bit more elegantly as: library(tidyr) df <- data.frame(v1 = 1:5, somestring = 6:10,

Re: [R] tidyverse repeating error: "object 'rlang_mut_env_parent' not found"

2017-08-14 Thread Hadley Wickham
The most likely explanation is you have a new version of dplyr/tibble and an old version of rlang. Try re-installing rlang. Hadley On Mon, Aug 14, 2017 at 9:26 AM, Szumiloski, John wrote: > UseRs, > > When doing some data manipulations using the tidyverse, I am

Re: [R] Inheritance for S3 classes

2017-08-08 Thread Hadley Wickham
You might find http://adv-r.hadley.nz/s3.html to be helpful (in particular, http://adv-r.hadley.nz/s3.html#constructors-1, gives my advice about subclass constructors) Hadley On Mon, Aug 7, 2017 at 7:06 PM, Kym Nitschke wrote: > Hi R Users, > > I am relatively new to

Re: [R] Math ops behaviour with multiple classes

2017-06-08 Thread Hadley Wickham
On Thu, Jun 8, 2017 at 2:45 PM, Bert Gunter wrote: > I think you may be confusing (S3) class and ?mode. Your point is well made, but to be precise, I think you should talk about the "type of" an object, not it's mode. mode() is a wrapper around typeof(), designed (I

Re: [R] [FORGED] Logical Operators' inconsistent Behavior

2017-05-21 Thread Hadley Wickham
On Fri, May 19, 2017 at 6:38 AM, S Ellison wrote: >> TRUE & FALSE is FALSE but TRUE & TRUE is TRUE, so TRUE & NA could be >> either TRUE or FALSE and consequently is NA. >> >> OTOH FALSE & (anything) is FALSE so FALSE & NA is FALSE. >> >> As I said *think* about it; don't

Re: [R] Confused about using data.table package,

2017-02-20 Thread Hadley Wickham
On Sun, Feb 19, 2017 at 3:01 PM, David Winsemius wrote: > >> On Feb 19, 2017, at 11:37 AM, C W wrote: >> >> Hi R, >> >> I am a little confused by the data.table package. >> >> library(data.table) >> >> df <- data.frame(w=rnorm(20, -10, 1), x= rnorm(20,

Re: [R] Is a list an atomic object? (or is there an issue with the help page of ?tapply ?)

2017-02-20 Thread Hadley Wickham
On Mon, Feb 20, 2017 at 7:31 AM, Martin Maechler wrote: >> Hervé Pagès >> on Tue, 14 Feb 2017 17:10:05 -0800 writes: > > > Hi, tapply() will work on any object 'X' that has a length > > and supports single-bracket subsetting.

Re: [R] Is a list an atomic object? (or is there an issue with the help page of ?tapply ?)

2017-02-15 Thread Hadley Wickham
It seems like this should be consistent with split(), since that's what actually powers the behaviour. Reading the description for split leads to this rather interesting example: tapply(mtcars, 1:11, I) Hadley On Tue, Feb 14, 2017 at 7:10 PM, Hervé Pagès wrote: > Hi, > >

Re: [R] Failure to understand namespaces in XML::getNodeSet

2017-01-31 Thread Hadley Wickham
WorkSet//Description") > > ## Produces the following error message. > Error in UseMethod("xml_find_all") : > no applicable method for 'xml_find_all' applied to an object of class > "character" > > > > R. Mark Sharp, Ph.D. > msh...@txbiomed.org

Re: [R] Failure to understand namespaces in XML::getNodeSet

2017-01-31 Thread Hadley Wickham
See the last example in ?xml2::xml_find_all or use xml2::xml2::xml_ns_strip() Hadley On Tue, Jan 31, 2017 at 9:43 AM, Mark Sharp wrote: > I am trying to read a series of XML files that use a namespace and I have > failed, thus far, to discover the proper syntax. I have a

Re: [R] Assessing the name of an object within an argument

2017-01-10 Thread Hadley Wickham
You might find http://adv-r.had.co.nz/Computing-on-the-language.html helpful. Hadley On Tue, Jan 10, 2017 at 2:49 AM, wrote: > Hi All, > > I have a function like > > my_func <- function(dataset) > { > some operation > } > > Now I would like not only to operate on the

Re: [R] ggplot aestetics: beginner question - I am lost in endless possibilites

2016-12-15 Thread Hadley Wickham
You are going to find your life much easier if you: * Organise your code so it's easier to read * Use a consistent naming scheme for your variables * Learn a bit more about how to modify variables succintly Here's my rewriting of your script to make it easier to see what's going on.

Re: [R] Unexpected interference between dplyr and plm

2016-11-29 Thread Hadley Wickham
On Tue, Nov 29, 2016 at 11:52 AM, William Dunlap wrote: >>The other option would be to load dplyr first (which would give the waring >> that >stats::lag was masked) and then later load plm (which should give a >> further >warning that dplyr::lag is masked). Then the plm::lag

Re: [R] on ``unfolding'' a json into data frame columns

2016-11-29 Thread Hadley Wickham
Two quick hints: * use simplifyDataFrame = FALSE in fromJSON() * read https://jennybc.github.io/purrr-tutorial/ls02_map-extraction-advanced.html (and https://jennybc.github.io/purrr-tutorial/) Hadley On Tue, Nov 29, 2016 at 8:06 AM, Daniel Bastos wrote: > Greetings! > >

Re: [R] Question about ‘The R Project’.

2016-11-14 Thread Hadley Wickham
>> We have a question about ‘The R Project’. >> >> It looks like it’s an open source software, but the document from the >> website shows that it’s free of use not free of price. >> >> Please, confirm us the if it cost fees to use it for commercial use. >> >> If needed, could you inform us the

Re: [R] workflow getting UTF-8 csv in and out of R on Mac (spreadsheet editor)

2016-09-02 Thread Hadley Wickham
You can use readr::write_excel_csv() which adds a BOM that forces excel to read as UTF-8. Hadley On Friday, September 2, 2016, Erich Neuwirth wrote: > read_excel in Hadley’s readxl package > should handle your encoding problems. > Writing Excel files on a Mac,

Re: [R] read.xlsx function crashing R Studio

2016-08-22 Thread Hadley Wickham
Or readxl. Hadley On Mon, Aug 22, 2016 at 5:54 AM, jim holtman wrote: > try the openxlsx package > > > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > > On Sun, Aug 21, 2016 at

Re: [R] lm() silently drops NAs

2016-07-26 Thread Hadley Wickham
> I think that's a bit too strict for me, so I wrote my own: > > na.warn <- function(object, ...) { > missing <- complete.cases(object) > if (any(missing)) { > warning("Dropping ", sum(missing), " rows with missing values", > call. = FALSE) > } > > na.exclude(object, ...) > } That

Re: [R] lm() silently drops NAs

2016-07-26 Thread Hadley Wickham
On Tue, Jul 26, 2016 at 3:24 AM, Martin Maechler wrote: > I have been asked (in private) Martin was very polite to not share my name, but it was me :) > > Hi Martin, > > y <- c(1, 2, 3, NA, 4) > x <- c(1, 2, 2, 1, 1) > > t.test(y ~ x) > lm(y ~ x)

Re: [R] Date Time in R

2016-07-26 Thread Hadley Wickham
I'd recommend reading up on how to create a minimal reproducible example (e.g. http://r4ds.had.co.nz/exploratory-data-analysis.html). It is unlikely anyone will be able to help you unless you can reliably communicate _exactly_ what you're doing. Unlike human languages, computer languages are

Re: [R] Build command in library(devtools)

2016-07-20 Thread Hadley Wickham
The first place to start is to make sure you have the latest version of devtools. If that doesn't work, please file an issue on devtools' GitHub. Hadley On Wednesday, July 20, 2016, Steven Yen wrote: > Here is what I found. I had to go back to as early as R 3.0.3 (March, >

Re: [R] About identification of CRAN CHECK machines in logs

2016-06-10 Thread Hadley Wickham
On Fri, Jun 10, 2016 at 8:27 AM, Marcelo Perlin wrote: > I don't know Hadley. But you can see evidence of "something" systematically > installing the packages in the log data. From my two CRAN packages I noticed > a high correlation in the number of downloads. > > Try the

Re: [R] About identification of CRAN CHECK machines in logs

2016-06-09 Thread Hadley Wickham
On Thu, Jun 9, 2016 at 9:24 AM, Marcelo Perlin wrote: > Hi, > > I recently released two packages (RndTexExams and GetTDData) in CRAN and > I'm trying to track the number of downloads and location of users. > > I wrote a simple script to download and analyze the log files

Re: [R] httr package syntax (PUT)

2016-06-02 Thread Hadley Wickham
On Wed, Jun 1, 2016 at 7:16 PM, Jared Rodecker wrote: > Greetings fellow R users. > > I'm struggling with the syntax of submitting a PUT request > > I'm trying to insert a few PUT requests into some legacy R code that I have > that performs daily ETL on a small database.

Re: [R] with vs. attach

2016-05-09 Thread Hadley Wickham
On Mon, May 9, 2016 at 7:12 AM, peter dalgaard wrote: > > On 09 May 2016, at 02:46 , Bert Gunter wrote: > >> ... To be clear, Hadley or anyone else should also feel free to set me >> straight, preferably publicly, but privately if you prefer. > > Not

Re: [R] with vs. attach

2016-05-09 Thread Hadley Wickham
On Sun, May 8, 2016 at 7:28 PM, Bert Gunter wrote: > Jeff: > > That's easy to do already with substitute(), since you can pass around > an unevaluated expression (a parse tree) however you like. As I read > it, (admittedly quickly) what it's main feature is that it allows

Re: [R] with vs. attach

2016-05-06 Thread Hadley Wickham
You may want to read http://rpubs.com/hadley/157957, which captures my latest thinking (and tooling) around this problem. Feedback is much appreciated. Hadley On Fri, May 6, 2016 at 2:14 PM, David Winsemius wrote: > >> On May 6, 2016, at 5:47 AM, Spencer Graves >>

Re: [R] installation of dplyr

2016-04-19 Thread Hadley Wickham
You normally see these errors when compiling on a vm that has very little memory. Hadley On Tue, Apr 19, 2016 at 2:47 PM, Ben Tupper wrote: > Hello, > > I am getting a fresh CentOS 6.7 machine set up with all of the goodies for R > 3.2.3, including dplyr package. I am

Re: [R] simple question on data frames assignment

2016-04-07 Thread Hadley Wickham
== is also vectorised, and you're better off with TRUE and FALSE rather than 1 and 0, so I'd recommend: colordata$response <- colordata$color == 'blue' Hadley On Thu, Apr 7, 2016 at 6:52 AM, David Barron wrote: > ifelse is vectorised, so just use that without the loop. > >

Re: [R] Updating github R packages

2016-02-17 Thread Hadley Wickham
It will be included in the next version of devtools - it's totally do-able, but no one has done it yet. Hadley On Wed, Feb 17, 2016 at 6:44 PM, Jeff Newmiller wrote: > AFAIK the answer is no. That would be one of the main drawbacks of depending > on github for

Re: [R] vjust unresponsive (ggplot2)

2015-12-23 Thread Hadley Wickham
vjust was always a hack that I never thought should work. The margins parameter is the correct way to solve this problem as of ggplot2 2.0.0. Hadley On Tuesday, December 22, 2015, Nordlund, Dan (DSHS/RDA) wrote: > Ista, > > You are correct, I was not at the latest release

Re: [R] Make a box-whiskers plot in R with 5 variables, color coded.

2015-12-16 Thread Hadley Wickham
On Tue, Dec 15, 2015 at 9:55 AM, Martin Maechler wrote: > > >[] > > > You are missing the closing bracket on the boxplot() > > command. Just finish with a ')' > > Hmm... I once learned > > '()' =: parenthesis/es > '[]' =: bracket(s) > '{}'

Re: [R] Make a box-whiskers plot in R with 5 variables, color coded.

2015-12-16 Thread Hadley Wickham
On Wed, Dec 16, 2015 at 9:34 AM, Hadley Wickham <h.wick...@gmail.com> wrote: > On Tue, Dec 15, 2015 at 9:55 AM, Martin Maechler > <maech...@stat.math.ethz.ch> wrote: >> >> >>[] >> >> > You are missing the closing brac

Re: [R] stopifnot with logical(0)

2015-12-14 Thread Hadley Wickham
On Sat, Dec 12, 2015 at 1:51 PM, Martin Maechler <maech...@stat.math.ethz.ch> wrote: >>>>>> Hadley Wickham <h.wick...@gmail.com> >>>>>> on Sat, 12 Dec 2015 08:08:54 -0600 writes: > > > On Sat, Dec 12, 2015 at 3:54 AM, M

Re: [R] stopifnot with logical(0)

2015-12-14 Thread Hadley Wickham
>> I wonder if R is missing an equality operator for this case. Currently: >> >> * == is suboptimal because it's vectorised >> * all.equal is suboptimal because it returns TRUE or a text string >> * identical is suboptimal because it doesn't do common coercions >> >> Do we need another function

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Hadley Wickham
On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler wrote: >> Henrik Bengtsson >> on Fri, 11 Dec 2015 08:20:55 -0800 writes: > > > On Fri, Dec 11, 2015 at 8:10 AM, David Winsemius > wrote: > >> >

Re: [R] Weird behaviour function args in ellipses

2015-12-11 Thread Hadley Wickham
On Fri, Dec 11, 2015 at 1:13 PM, Duncan Murdoch wrote: > On 11/12/2015 1:52 PM, Mario José Marques-Azevedo wrote: >> >> Hi Duncan and David, >> >> Thank you for explanation. I'm really disappointed with this R "resource". >> I think that partial match, mainly in function

[R] R Consortium projects

2015-11-04 Thread Hadley Wickham
focussed on funding people who have the skills to solve a problem. In the future, we will explore how to match up people with skills and people with problems. * Proposals are due Jan 10. Please let me know if you have any questions! Hadley Wickham Chair, ISC -- http://had.co.nz

Re: [R] Achieve independent fine user control of ggplot geom settings when using groups in multiple geom's

2015-10-30 Thread Hadley Wickham
I'd recommend reading the ggplot2 book - learning more about how scales work in ggplot2 will help you understand why this isn't possible. Hadley On Thu, Oct 29, 2015 at 6:31 PM, sbihorel wrote: > Thank for your reply, > > I may accept your point about the

Re: [R] Control of x-axis variable ordering in ggplot

2015-10-23 Thread Hadley Wickham
You have two problems: * geom_line() always draws from right-to-left * you're defining colour outside of the plot in a very non-ggplot2 way. Here's how I'd do it: library(ggplot2) data <- data.frame( x = rep(1:4, each = 25), y = rep(1:25, times = 4), g = rep(1:4, each = 25) ) data$x <-

Re: [R] retaining characters in a csv file

2015-09-22 Thread Hadley Wickham
The problem is that quotes in csv files are commonly held to me meaningless (i.e. they don't automatically force components to be strings). Earlier this morning I committed a fix to readr so that numbers starting with a sequence of zeros are read as character strings. You may want to try out the

Re: [R] Unexpected/undocumented behavior of 'within': dropping variable names that start with '.'

2015-09-20 Thread Hadley Wickham
The problem is that within.data.frame calls as.list.environment with the default value of all.names = FALSE. I doubt this is a deliberate feature, and is more likely to be a minor oversight. Hadley On Sun, Sep 20, 2015 at 11:49 AM, Brian wrote: > Dear List, > > Somewhere I

Re: [R] ggplot2 scale_shape_manual with large numbers instead of shapes

2015-08-27 Thread Hadley Wickham
Something like this? df - data.frame( x = runif(30), y = runif(30), z = factor(1:30) ) ggplot(df, aes(x, y)) + geom_point(aes(shape = z), size = 5) + scale_shape_manual(values = c(letters, 0:9)) Hadley On Thu, Aug 27, 2015 at 4:48 PM, Marian Talbert mtalb...@usgs.gov wrote: I'm

Re: [R] Issues with RPostgres

2015-08-27 Thread Hadley Wickham
On Thu, Aug 27, 2015 at 3:46 PM, John McKown john.archie.mck...@gmail.com wrote: On Thu, Aug 27, 2015 at 2:29 PM, Abraham Mathew mathewanalyt...@gmail.com wrote: I have a user-defined function that I'm using alongside a postgresql connection to summarize some data. I've connected to the

Re: [R] How are packages installed with install_github() updated in RStudio?

2015-08-18 Thread Hadley Wickham
RStudio just calls the same underlying R functions, so it doesn't make any difference that you're using RStudio. Currently, there's no automatic way to update packages installed from github. Hadley On Tue, Aug 18, 2015 at 8:14 AM, John Kane jrkrid...@inbox.com wrote: Hi Michal, Because

Re: [R] writing binary data from RCurl and postForm

2015-08-05 Thread Hadley Wickham
I think that is because the value returned from postForm has an attribute; remove it by casting the return to a vector fl - tempfile(fileext=.pdf) writeBin(as.vector(postForm(url, binary=TRUE)), fl) The httr package might also be a good bet writeBin(content(POST(url)), fl) Or

Re: [R] dplyr and function length()

2015-08-04 Thread Hadley Wickham
No, the effect I described has nothing to do wit USING dplyr. It occurs with any (preexisting) data.frame once dplyr is LOADED (require(dplyr). It is this silent, sort of backward acting effect that disturbs me. You're going to need to provide some evidence for that charge: dplyr does not

Re: [R] dplyr and function length()

2015-08-04 Thread Hadley Wickham
length(df[,1]). Both commands will return n. However, once dplyr is loaded, length(df[,1]) will return a value of 1. length(df$m1) and also length(df[[1]]) will correctly return n. I know that using length() may not be the most elegant or efficient way to get the value of n. However,

Re: [R] attributes in dplyr and haven

2015-08-04 Thread Hadley Wickham
Install the latest version of dplyr? Should be fixed there. Hadley On Tue, Aug 4, 2015 at 9:40 AM, Conklin, Mike (GfK) mike.conk...@gfk.com wrote: I read in spss files using haven's read_spss. Each column then gets attributes assigned named label - a long description of the variable class -

Re: [R] ggplot2 - geom_text() with date as x-axis

2015-07-30 Thread Hadley Wickham
I'm a bit confused what you're trying to accomplish - the mix of annotate() and geom_text() is confusing. The following code works for me, and I think might be what you want: ggplot(ins, aes(td, glucose)) + geom_point(colour = red) + geom_line(colour = blue) + annotate(text, x = texdat, y =

Re: [R] ggplot2 - Specifying Colors Manually

2015-07-22 Thread Hadley Wickham
Try this: ggplot(mydf,aes(x)) + geom_line(aes(y = y1, colour = y1)) + geom_line(aes(y = y2, colour = y2)) + scale_color_manual(values = c(y1 = green4, y2 = blue2)) Note that you don't need to use `mydf` and names in the manual scale should match the values in the aes() calls.

Re: [R] For Hadley Wickham: Need for a small fix in haven::read_spss

2015-07-20 Thread Hadley Wickham
(FWIW this would've been better send to me directly or filed on github, rather than sent to R-help) I think this is more of a problem with the way that you're accessing the info, than the design of the underlying structure. I'd do something like this: attr_default - function(x, which, default) {

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
...@appl-ecosys.com wrote: On Fri, 10 Jul 2015, Hadley Wickham wrote: You shouldn't be explicitly opening a device in a knitr document. Hadley, Didn't think so. I think maybe you should post a minimal document so we can figure out what's going wrong. Agreed. Attached are the raw

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley On Friday, July 10, 2015, Rich Shepard rshep...@appl-ecosys.com wrote: Hadley's ggplot2 book is quite old and a new version is in the works, but not yet out. I've been using lattice graphics but the knitr

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
You shouldn't be explicitly opening a device in a knitr document. I think maybe you should post a minimal document so we can figure out what's going wrong. Hadley On Friday, July 10, 2015, Rich Shepard rshep...@appl-ecosys.com wrote: On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Hadley Wickham
It doesn’t appear to me that mpfr was ever designed to handle expressions as the first argument. This could be a start. Obviously one would wnat to include code to do other substitutions probably using the all.vars function to pull out the other “constants” and ’numeric’ values to make

Re: [R] what constitutes a 'complete sentence'?

2015-07-03 Thread Hadley Wickham
It might be a line break problem - I think you want: Description: Functions designed to test for single gene/phenotype association and for pleiotropy on genetic and genomic data. Hadley On Fri, Jul 3, 2015 at 10:09 AM, Federico Calboli federico.calb...@helsinki.fi wrote: Hi All, I am

Re: [R] what constitutes a 'complete sentence'?

2015-07-03 Thread Hadley Wickham
In that case, you need to create a minimal reproducible example and make it publicly available. Hadley On Friday, July 3, 2015, Federico Calboli federico.calb...@helsinki.fi wrote: On 3 Jul 2015, at 12:14, Hadley Wickham h.wick...@gmail.com javascript:; wrote: It might be a line break

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Hadley Wickham
On Tue, Jun 16, 2015 at 12:24 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have a data frame: md - data.frame(a = c(3,5,4,5,3,5), b = c(5,5,5,4,4,1), c = c(1,3,4,3,5,5), device = c(1,1,2,2,3,3)) myvars = c(a, b, c) md[2,3] - NA md[4,1] - NA md I want to

Re: [R] Problem with particular file in XML package?

2015-05-28 Thread Hadley Wickham
I have also seen this problem on a student's windows machine (with R 3.2.0 and on multiple mirrors). It appeared that the package zip itself was being corrupted (with an error to the tune of downloaded file size does not agree with actual file size). The most likely explanation that I could come

Re: [R] Rtools 3.3 is not compatible with R 3.2.0.?

2015-04-21 Thread Hadley Wickham
It's been fixed in the dev version, and I'm planning on submitting to CRAN in the near future. Hadley On Tue, Apr 21, 2015 at 6:01 PM, Shi, Tao shida...@yahoo.com wrote: hi list, Any updates on this issue? Thank you very much! Tao devtools::install_github(rstudio/packrat) WARNING:

Re: [R] library(xlsx) fails with an error: Error: package ‘rJava’ could not be loaded

2015-04-20 Thread Hadley Wickham
You might want to try readxl instead, as it doesn't have any external dependencies. Hadley On Sat, Apr 18, 2015 at 3:07 PM, John Sorkin jsor...@grecc.umaryland.edu wrote: Windows 7 64-bit R 3.1.3 RStudio 0.98.1103 I am having difficulty loading and installing the xlsx package. The loading

Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread Hadley Wickham
On Mon, Apr 20, 2015 at 1:57 PM, arnaud gaboury arnaud.gabo...@gmail.com wrote: On Mon, Apr 20, 2015 at 6:09 PM, William Dunlap wdun...@tibco.com wrote: The hyphen without a following digit confuses tidyr::extract_numeric(). E.g., extract_numeric(23 ft-lbs) Warning message: In

Re: [R] open xlsx file using read.xls function of gdata package

2015-04-03 Thread Hadley Wickham
You might try the readxl package - it's only available on github but it reads both xlsx and xls. All going well, it should be on its way to CRAN next week. Hadley On Friday, April 3, 2015, Luigi Marongiu marongiu.lu...@gmail.com wrote: Dear all, I am trying to open excel files using the gdata

Re: [R] idiom for constructing data frame

2015-04-03 Thread Hadley Wickham
On Tue, Mar 31, 2015 at 6:42 PM, Sarah Goslee sarah.gos...@gmail.com wrote: On Tue, Mar 31, 2015 at 6:35 PM, Richard M. Heiberger r...@temple.edu wrote: I got rid of the extra column. data.frame(r=seq(8), foo=NA, bar=NA, row.names=r) Brilliant! After much fussing, including a disturbing

Re: [R] Using and abusing %% (was Re: Why can't I access this type?)

2015-03-27 Thread Hadley Wickham
I didn't dispute whether '%%' may be useful -- I just pointed out that it is slow. However, it is only part of the problem: 'filter()' and 'select()', although aesthetically pleasing, also seem to be slow: all.states - data.frame(state.x77, Name = rownames(state.x77)) f1 - function() +

Re: [R] readHTMLTable() in XML package

2015-03-02 Thread Hadley Wickham
This somewhat simpler rvest code does the trick for me: library(rvest) library(dplyr) i - 1:10 urls - paste0('http://games.crossfit.com/scores/leaderboard.php?stage=5', 'sort=0division=1region=0numberperpage=100competition=0frontpage=0',

Re: [R] dplyr: producing a good old data frame

2015-02-25 Thread Hadley Wickham
Hi John, Just printing the result gives a good indication where the problem lies: frm %% rowwise() %% do(MM=max(as.numeric(.))) Source: local data frame [6 x 1] Groups: by row MM 1 dbl[1] 2 dbl[1] 3 dbl[1] 4 dbl[1] 5 dbl[1] 6 dbl[1] do() is designed to produce scalars (e.g. a linear

Re: [R] %%

2015-02-17 Thread Hadley Wickham
On Tue, Feb 17, 2015 at 6:02 PM, Hervé Pagès hpa...@fredhutch.org wrote: On 02/17/2015 02:10 PM, Erich Neuwirth wrote: AFAIK dplyr imports magrtittr. So dplyr ses %% from migrittr, it does not have its own version. But it has its own man page so who knows? If you import and re-export a

Re: [R] Shiny User Group

2015-02-12 Thread Hadley Wickham
Maybe https://groups.google.com/forum/#!forum/shiny-discuss ? Hadley On Thu, Feb 12, 2015 at 9:07 AM, Doran, Harold hdo...@air.org wrote: I found a google user group for shiny, and am curious if there is an SIG as well. Didn't see one in my searches, but looking for an active place to ask

Re: [R] Package build help

2015-02-11 Thread Hadley Wickham
On Sun, Feb 8, 2015 at 5:15 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 08/02/2015 4:06 PM, Glenn Schultz wrote: Hello All, I am in the final stages of building my first package BondLab and the check throughs the following warning. I think this is namespace thing. I have not

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread Hadley Wickham
On Thu, Jan 29, 2015 at 11:43 AM, Alan Yong alany...@caltech.edu wrote: Much thanks to everyone for their recommendations! I agree that fishing in the global environment isn't ideal only shows my budding understanding of R. For now, I will adapt Chel Hee's

Re: [R] Latest version of Rtools is incompatible with latest version of R !!

2015-01-16 Thread Hadley Wickham
Funnily, this problem disappears when I use RTools31.exe. And, I am not the only one facing this issue. A lot of people in my group (in which we all are learning R) are facing the same problem. I am really puzzled as to why RTools32.exe isn't compatible with R 3.1.2 !! Thanks again for

Re: [R] stringr::str_split_fixed query

2015-01-15 Thread Hadley Wickham
FWIW this is fixed in the dev version of stringr which uses stringi under the hood: stringr::str_split_fixed('ab','',2) [,1] [,2] [1,] a b stringr::str_split_fixed('ab','',3) [,1] [,2] [,3] [1,] a b Hadley On Wed, Jan 14, 2015 at 12:47 PM, David Barron dnbar...@gmail.com wrote:

  1   2   3   4   5   6   7   8   9   10   >