similar to: vapply definition question

Displaying 20 results from an estimated 30000 matches similar to: "vapply definition question"

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
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
2015 Aug 03
2
'vapply' not returning list element names when returned element is a length-1 list
Hi all Sorry for the confusing title. I noticed the following inconsistency: If i have a function that returns a named list with 2 (or more) elements, then using 'vapply' retains the names of the elements: > vapply(1:3, function(x) list("foo" = "bar", "hello" = "world"), > vector("list", 2)) [,1] [,2] [,3] foo
2018 Mar 13
1
Possible Improvement to sapply
Could your code use vapply instead of sapply? vapply forces you to declare the type and dimensions of FUN's output and stops if any call to FUN does not match the declaration. It can use much less memory and time than sapply because it fills in the output array as it goes instead of calling lapply() and seeing how it could be simplified. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue,
2018 Mar 13
0
Possible Improvement to sapply
Quite possibly, and I?ll look into that. Aside from the work I was doing, however, I wonder if there is a way such that sapply could avoid the overhead of having to call the identical function to determine the conditional path. From: William Dunlap [mailto:wdunlap at tibco.com] Sent: Tuesday, March 13, 2018 12:14 PM To: Doran, Harold <HDoran at air.org> Cc: Martin Morgan <martin.morgan
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 <-
2018 Mar 13
2
Possible Improvement to sapply
Martin In terms of context of the actual problem, sapply is called millions of times because the work involves scoring individual students who took a test. A score for student A is generated and then student B and such and there are millions of students. The psychometric process of scoring students is complex and our code makes use of sapply many times for each student. The toy example used
2018 Mar 13
2
Possible Improvement to sapply
FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut some corners compared to identical(): > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) Unit: nanoseconds expr min lq mean median uq max neval identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584 100 isFALSE(FALSE) 713 761 1133.53 809.5 871.5
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
2018 Mar 13
0
Possible Improvement to sapply
On 03/13/2018 09:23 AM, Doran, Harold wrote: > While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function > > if (!identical(simplify, FALSE) && length(answer)) > > This seems superfluous to me,
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
2012 Mar 01
3
Converting a string vector with names to a numeric vector with names
Not paying close attention to detail, I entered the equivalent of pstr<-c("b1=200", "b2=50", "b3=0.3") when what I wanted was pnum<-c(b1=200, b2=50, b3=0.3) There was a list thread in 2010 that shows how to deal with un-named vectors, but the same lapply solution doesn't seem to work here i.e., pnum<-lapply(pstr, as.numeric) or similar vapply
2015 Mar 01
2
iterated lapply
I think the discussion of this issue has gotten more complicated than necessary. First, there really is a bug. You can see this also by the fact that delayed warning messages are wrong. For instance, in R-3.1.2: > lapply(c(-1,2,-1),sqrt) [[1]] [1] NaN [[2]] [1] 1.414214 [[3]] [1] NaN Warning messages: 1: In FUN(c(-1, 2, -1)[[3L]], ...) : NaNs produced 2: In
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) {
2018 Mar 14
0
Possible Improvement to sapply
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Tue, 13 Mar 2018 10:12:55 -0700 writes: > FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut > some corners compared to identical(): > > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) > Unit: nanoseconds > expr
2018 Mar 13
4
Possible Improvement to sapply
While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function if (!identical(simplify, FALSE) && length(answer)) This seems superfluous to me, in particular this part: !identical(simplify, FALSE) The preceding
2014 Jan 03
1
Tab formatting in dummy.coef.R
Happy New Year I recognize this is a low priority issue, but... I'll fix it if you let me. There are some TABs where R style calls for 4 spaces. For example R-3.0.2/src/library/stats/R/dummy.coef.R. I never noticed this until today, when I was stranded on a deserted island with only the R source code and a Swiss Army knife (vi). Now I realize my ~.vimrc has tabstop set at 2, and it makes
2006 Mar 10
2
lapply and list attributes
Hi I have a list that has attributes: attributes(lis[2]) $names [1] "150096_at" I want to use those attributes in a function and then use lapply to apply that function to every element of the list, eg for simplicity's sake: my.fun <- function(x) { attributes(x) } Then l2 <- lapply(lis, my.fun) It seems that "attributes(x)" within the function is not the
2018 May 03
1
Converting a list to a data frame
>>>>> David L Carlson <dcarlson at tamu.edu> >>>>> on Wed, 2 May 2018 21:43:52 +0000 writes: > Typo: dat[[z]] should be x[[z]]: > > x2 <- do.call(rbind, lapply(names(x), function(z) > data.frame(type=z, x[[z]]))) > x2 > type x y > 1 A 1 3 > 2 A 2 4 > 3 B 5 7 > 4 B 6 8 > >
2018 May 02
0
Converting a list to a data frame
Typo: dat[[z]] should be x[[z]]: x2 <- do.call(rbind, lapply(names(x), function(z) data.frame(type=z, x[[z]]))) x2 type x y 1 A 1 3 2 A 2 4 3 B 5 7 4 B 6 8 David C -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of David L Carlson Sent: Wednesday, May 2, 2018 3:51 PM To: William Dunlap <wdunlap at tibco.com>; Kevin E.