similar to: A "safe" do.call

Displaying 20 results from an estimated 50000 matches similar to: "A "safe" do.call"

2008 Feb 23
2
Aliasing a function
A simple way to alias a function is to do : g <- function(a = 1, b = 2, c = 3) a + b * c f <- function(...) g(...) but formals (etc) is no longer very helpful. Is there an easy way to programmatically create: f <- function(a=1, b=2, c=3) g(a=a, b=b, c=c) This comes up in ggplot2 where I alias many functions to hide the fact that I'm using proto in the background, and I'd like
2010 Oct 08
2
What do you call the value that represents a missing argument?
Hi all, What's the official name for the value that represents a missing argument? e.g. formals(plot)$x str(formals(plot)$x) deparse(formals(plot)$x) is.symbol(formals(plot)$x) What's the correct way to create an object like this? (for example if you are manipulating the formals of a function to add an argument with no default value, as in http://stackoverflow.com/questions/3892580/).
2018 Aug 23
7
conflicted: an alternative conflict resolution strategy
Hi all, I?d love to get your feedback on the conflicted package, which provides an alternative strategy for resolving ambiugous function names (i.e. when multiple packages provide identically named functions). conflicted 0.1.0 is already on CRAN, but I?m currently preparing a revision (<https://github.com/r-lib/conflicted>), and looking for feedback. As you are no doubt aware, R?s default
2013 Feb 18
2
quote() vs quote(expr=)
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() or bquote() or formals(plot)$x Hadley -- Chief Scientist, RStudio
2018 Apr 27
5
predict.glm returns different results for the same model
Hi all, Very surprising (to me!) and mystifying result from predict.glm(): the predictions vary depending on whether or not I use ns() or splines::ns(). Reprex follows: library(splines) set.seed(12345) dat <- data.frame(claim = rbinom(1000, 1, 0.5)) mns <- c(3.4, 3.6) sds <- c(0.24, 0.35) dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd = sds[dat$claim + 1])) dat <-
2015 Jan 29
2
[Q] Get formal arguments of my implemented S4 method
I wish it didn't have to depend on the name '.local'. Back when I wrote a lot of S4 methods I avoided the auto-generated .local and named the local function something that made sense so that is was easier for a user to track down the source of an error. E.g., define the generic QQQ with numeric and integer methods: setGeneric("QQQ", function(x, ...)NULL)
2017 Mar 19
3
RFC: (in-principle) native unquoting for standard evaluation
Michael Lawrence (as last in long series of posters)... > Yes, it would bind the language object to the environment, like an > R-level promise (but "promise" of course refers specifically to just > _lazy_ evaluation). > > For the uqs() thing, expanding calls like that is somewhat orthogonal > to NSE. It would be nice in general to be able to write something like >
2009 Apr 17
1
cast function in package reshape
Hello R useRs, I have a function which returns a list of functions : freq1 <- function(x) { lev <- unique(x[!is.na(x)]) nlev <- length(lev) args <- alist(x=) if (nlev == 1) { body <- c("{", "sum(!is.na(x))", "}") f <- function() {} formals(f) <- as.pairlist(args) body(f) <- parse(text = body) namef <-
2013 Oct 21
1
Set operation generics
Hi all, Would anyone be interested in reviewing a patch to make the set operations (union, intersect, setdiff, setequal, is.element) generic? Thanks, Hadley -- Chief Scientist, RStudio http://had.co.nz/
2015 Jan 29
1
[Q] Get formal arguments of my implemented S4 method
Would we really need the special class or would simply checking the formals of the method against those of the generic be simple and fast enough? On Thu, Jan 29, 2015 at 9:41 AM, John Chambers <jmc at r-project.org> wrote: > I wouldn't want to add more to the current approach; if someone would like > to devote some time, the much preferable idea IMO would be to replace the >
2010 Mar 10
2
ggplot2: "varwidth"-equivalent for geom_boxplot?
Hi, Is there such a thing? If no: is it easily simulated? thanks, Joh
2010 Aug 21
3
problems with merge() - the output has many repeated lines
Hi everyone, I have been merging many big dataframes (about 80000 rows each) and I never had this problem, but now it happened to me and I want to know if someone knows what could be happening. The final dataframe has many rows, an impossible number! I have done edit(dataframe) and I saw that there are many repeated rows (all equal). Thanks for any help, Cec?lia Carmo Universidade de
2005 Dec 26
1
Seg fault with trace
(Under 2.2.0, Mac) I have been unable to reduce this to a simple case, so I'll include my full code, and my intentions. The problem I'm trying to solve is that while many defaults (eg. na.rm=F, drop=T) make sense for interactive programming, they tend to be a bit of a pain when developing a package. For example, I often forget to use drop=FALSE, only test with multiple columns and then
2008 Feb 05
2
using image to show RGB image data ?
Hello all, I'm now using image() to show image data (in my case dumps of SOM weights) but would like to show RGB colour data, not just single "z" colour values. I've currently been using seq() to skip 4 values, so I can show the R, G or B channels separately as "z". But is there a way I can show all three channels simultaneously as a proper colour image? Thanks, B.
2015 Jan 29
3
[Q] Get formal arguments of my implemented S4 method
On Jan 28, 2015, at 6:37 PM, Michael Lawrence <lawrence.michael at gene.com> wrote: > At this point I would just due: > > formals(body(method)[[2L]]) > > At some point we need to figure out what to do with this .local() confusion. Agreed, definitely. The current hack is to avoid re-matching arguments on method dispatch, so a fix would need to be fairly deep in the
2016 Nov 26
3
ifelse() woes ... can we agree on a ifelse2() ?
Just stating, in 'ifelse', 'test' is not recycled. As I said in "R-intro: length of 'ifelse' result" (https://stat.ethz.ch/pipermail/r-devel/2016-September/073136.html), ifelse(condition, a, b) returns a vector of the length of 'condition', even if 'a' or 'b' is longer. On current 'ifelse' code in R: * The part ans[nas] <- NA
2009 Dec 04
2
[ggplot2] Wind rose orientation
Aloha all, I love using ggplot. It took a while to get used to the grammar of graphics, but it is starting to get easy now that I am thinking in a more structured way. A question. I'm making a wind rose that I'd like to be oriented with due north straight up. I've discovered that the orientation is sensitive to how north is represented. When north is represented as 0,
2011 Apr 13
2
Line plots in base graphics
Am I missing something obvious on how to draw multi-line plots in base graphics? In ggplot2, I can do: data(Oxboys, package = "nlme") library(ggplot2) qplot(age, height, data = Oxboys, geom = "line", group = Subject) But in base graphics, the best I can come up with is this: with(Oxboys, plot(age, height, type = "n")) lapply(split(Oxboys[c("age",
2008 Jan 15
4
Overlay plots from different data sets using the Lattice package
#After spending the entire day working on this question, I have decided to reach out for support: #I am trying to overlay a densityplot from one data set over a histogram of another, if I were to plot the two individually, they would look like: # data frame construction data.frame.A <- data.frame(rnorm(12*8), c(rep("one", 4), rep("two", 4), rep("three", 4)),
2009 May 19
4
Qs: The list of arguments, wrapping functions...
Hi. I'm pretty new to R, but I've been programming in other languages for some time. I have a couple of questions regarding programming with function objects. 1. Is there a way for a function to refer generically to all its actual arguments as a list? I'm thinking of something like the @_ array in Perl or the arguments variable in JavaScript. (By "actual" I mean the ones