similar to: 'vapply' not returning list element names when returned element is a length-1 list

Displaying 20 results from an estimated 4000 matches similar to: "'vapply' not returning list element names when returned element is a length-1 list"

2015 Aug 05
0
'vapply' not returning list element names when returned element is a length-1 list
> -----Original Message----- > From: R-devel [mailto:r-devel-bounces at r-project.org] On Behalf Of Dean Attali > If i have a function that returns a named list with 2 (or more) elements, > then using 'vapply' retains the names of the elements: > .... > But if the function only returns one element, then the name "foo" is lost vapply _always simplifies_
2015 Aug 06
0
'vapply' not returning list element names when returned element is a length-1 list
Quote---------------- > If i have a function that returns a named list with 2 (or more) elements, > then using 'vapply' retains the names of the elements: > .... > But if the function only returns one element, then the name "foo" is lost vapply _always simplifies_ according to the documentation. In the first case (function return value contains more than one
2015 Jun 30
2
Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
Hi r-devel If you define a function named `show` or attach a package with an exported `show` function, then printing/vieweing S4 objects breaks. This is probably because the `print` function calls `show`, which is now masked. Example: show <- function() {} > setClass("Person", slots = list(name = "character")) > tom <- new("Person", name =
2015 Jul 12
2
Why no support for 3-digit HEX colours?
When specifying an RGB colour in R, is there a strong reason not to accept 3-character HEX codes? In CSS and many other languages, a colour of "#ABC" is automatically converted to "#AABBCC", and I was wondering if R could support that as well, or if it was a conscious decision to not support it. --- http://deanattali.com [[alternative HTML version deleted]]
2020 Jul 10
2
lapply and vapply Primitive Documentation
The documentation of ?lapply includes: > lapply and vapply are primitive functions. However, both evaluate to FALSE in `is.primitive()`: is.primitive(vapply) #FALSE is.primitive(lapply) #FALSE It appears that they are not primitives and that the documentation might be outdated. Thank you for your time and work. Cole Miller P.S. During research, my favorite `help()` is
2014 Dec 17
2
vapply definition question
vapply <- function(X, FUN, FUN.VALUE, ..., USE.NAMES = TRUE) { FUN <- match.fun(FUN) if(!is.vector(X) || is.object(X)) X <- as.list(X) .Internal(vapply(X, FUN, FUN.VALUE, USE.NAMES)) } This is an implementor question. Basically, what happened to the '...' args in the call to the .Internal? cf lapply:, where the ... is passed. lapply <- function (X, FUN, ...)
2014 Apr 12
1
vapply confusion
The following code seems to contain an inconsistency in the behavior of vapply(). Am I missing something here? ## This function assumes v is a 3d vector, beta a scalar. f3d <- function(v,beta) { v+beta } ## This expression applies f3d to a vector of scalars, and ## specifies the template 'array(10,3)' for the return value. dat <- vapply(seq(0,1,length=10), function(beta) {
2015 Jul 08
5
Graphical User Interface (GUI)
I'd like to create a user interface for my R code and have only seen mostly older posts on the subject. I'm not looking for an IDE for development, but something that the end user of the software would use. So something that would involve displaying buttons, listboxes, and drop down menus to a user that will facilitate various actions. I doubt there is anything Visual Studio-like that
2014 Dec 17
0
vapply definition question
On 12/16/2014 08:20 PM, Mick Jordan wrote: > vapply <- function(X, FUN, FUN.VALUE, ..., USE.NAMES = TRUE) > { > FUN <- match.fun(FUN) > if(!is.vector(X) || is.object(X)) X <- as.list(X) > .Internal(vapply(X, FUN, FUN.VALUE, USE.NAMES)) > } > > This is an implementor question. Basically, what happened to the '...' args in > the call to the
2016 Feb 08
2
inconsistency in treatment of USE.NAMES argument
Hi, Both vapply() and sapply() support the 'USE.NAMES' argument. According to the man page: USE.NAMES: logical; if ?TRUE? and if ?X? is character, use ?X? as ?names? for the result unless it had names already. But if 'X' has names already and 'USE.NAMES' is FALSE, it's not clear what will happen to the names. Are they going to propagate to the result
2016 Feb 11
2
inconsistency in treatment of USE.NAMES argument
Changing the vapply() behavior makes sense in principle. I analyzed the CRAN code base using the R parser and found 143 instances of calling vapply with USE.NAMES=FALSE. These would need to be inspected to understand the consequences of the change. For reference: /AzureML/R/datasets.R:226 /BBmisc/R/toRangeStr.R:33 /DBI/R/DBDriver.R:205 /Kmisc/R/str_rev.R:37 /Matrix/R/diagMatrix.R:98
2020 Apr 14
4
Suggestion/opinions: add a `absolute` param to `normalizePath()` to force returning an absolute path
This request stems off a bug report I posted https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17757 where it was determined the current behaviour is as expected. To recap: when given a real file, normalizePath() always* returns the full absolute path. When given a non-existent file, normalizePath() returns a full path on Windows but it returns the input on other systems*. I'd argue that
2015 Jun 30
0
Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
A slightly simpler formulation of the problem is: show <- function(...) stop("My show!") methods::setClass("Person", slots = list(name = "character")) methods::new("Person", name = "Tom") #> Error in (function (...) : My show! Hadley On Tue, Jun 30, 2015 at 9:02 AM, Dean Attali <daattali at gmail.com> wrote: > Hi r-devel >
2012 Apr 19
2
Trouble with [sv]apply
Friends I clearly donot understand how sapply and vapply work. What I have is a function that returns a matrix with an indeterminate number of rows (some times zero) but a constant number of columns. I cannot reliably use an apply function to assemble the matrices into a matrix. I am not sure it is possible. I can demonstrate the core of my confusion with this simple code. A.f <-
2020 Jan 23
1
[External] Re: rpois(9, 1e10)
On 1/20/20 12:33 PM, Martin Maechler wrote: > > It's really something that should be discussed (possibly not > here, .. but then I've started it here ...). > > The NEWS for R 3.0.0 contain (in NEW FEATURES) : > > * Functions rbinom(), rgeom(), rhyper(), rpois(), rnbinom(), > rsignrank() and rwilcox() now return integer (not double) > vectors.
2017 Mar 23
1
A question on stats::as.hclust.dendrogram
Hi all, This is the first time I'm writing to R-devel, and this time I'm just asking for the purpose for a certain line of code in stats::as.hclust.dendrogram, which comes up as I'm trying to fix dendextend. The line in question is at line 128 of dendrogram.R in R-3.3.3, at stats::as.hclust.dendrogram: stopifnot(length(s) == 2L, all( vapply(s, is.integer, NA) )) Is there any
2015 Jun 30
2
Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
On 30/06/2015 1:57 PM, Hadley Wickham wrote: > A slightly simpler formulation of the problem is: > > show <- function(...) stop("My show!") > methods::setClass("Person", slots = list(name = "character")) > methods::new("Person", name = "Tom") > #> Error in (function (...) : My show! Just to be clear: the complaint is
2011 Aug 22
1
Data Frame Indexing
Hello, I've been dealing with a set of values that contain time stamps and part of my summary needs to look at just weekend data. In trying to limit the data I've found a large difference in performance in the way I index a data frame. I've constructed a minimal example here to try to explain my observation. is.weekend <- function(x) { tm <-
2019 Feb 19
4
code for sum function
The algorithm does make a differece. You can use Kahan's summation algorithm (https://en.wikipedia.org/wiki/Kahan_summation_algorithm) to reduce the error compared to the naive summation algorithm. E.g., in R code: naiveSum <- function(x) { s <- 0.0 for(xi in x) s <- s + xi s } kahanSum <- function (x) { s <- 0.0 c <- 0.0 # running compensation for lost
2013 Mar 12
2
Bugs due to naive copying of list elements
Several bugs are present in R-2.15.3 and R-alpha due to naive copying of list elements. The bug below is due to naive copying in subset.c (with similar bugs for matrices and arrays): a<-list(c(1,2),c(3,4),c(5,6)) b<-a[2:3] a[[2]][2]<-9 print(b[[1]][2]) Naive copying in mapply.c leads to the following bug: X<-1+1 f<-function(a,b) X A<-mapply(f,c(1,2,3),c(4,5,6),SIMPLIFY=FALSE)