Displaying 20 results from an estimated 800 matches similar to: "Data Frame Indexing"
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
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  
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
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.
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, ...)
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
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) {
 
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
2020 Nov 17
3
formatting issue with gcc 9.3.0 on Ubuntu on WSL2
I just got a new Windows laptop (i7, 10th generation CPU), installed
'Windows Subsystem for Linux 2' and then installed Ubuntu 20.04 and
used 'apt-get install' to install packages that the R build seems
to require.  In particular, I am using gcc version 9.3.0.   The
build went without a hitch but the tests showed that deparse(1e-16)
produced "1.00000000000000e-16" instead
2025 Jan 23
1
Depends: R (>= 4.1) for packages that use |> and \(...)
Many thanks to Henrik for remembering the report in Bugzilla and to
Kurt for implementing the change and finding out the true number of
affected packages.
On Wed, 22 Jan 2025 15:34:41 -0500
Ian Farm <ian.farm at maine.edu> wrote:
> Would packages using the underscore placeholder with the native pipe
> need to also depend on R >= 4.2.0?
That's a good find! For the R >= 4.2
2020 Nov 18
2
formatting issue with gcc 9.3.0 on Ubuntu on WSL2
On Wed, 18 Nov 2020 at 10:26, Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>
> On 11/17/20 9:34 PM, Bill Dunlap wrote:
> > I just got a new Windows laptop (i7, 10th generation CPU), installed
> > 'Windows Subsystem for Linux 2' and then installed Ubuntu 20.04 and
> > used 'apt-get install' to install packages that the R build seems
> > to
2023 Mar 02
3
tab-complete for non-syntactic names could attempt backtick-wrapping
There turn out to be a few more things to fix.
One problem is easy to solve: vapply() needs a third argument
specifying the type of the return value. (Can we have unit tests for
tab completion?)
The other problem is harder: `comps` defaults to an empty string, and
you can't have a symbol consisting of an empty string, because this
value is internally reserved for missing function arguments.
2025 May 23
1
Bug in prettyNum
? Fri, 23 May 2025 11:47:33 +0000
Marttila Mikko via R-devel <r-devel at r-project.org> ?????:
> When called with a numeric vector, the `replace.zero` argument is
> disregarded.
> 
> > prettyNum(0, zero.print = "- ", replace.zero = TRUE)  
> [1] "-"
> Warning message:
> In .format.zeros(x, zero.print, replace = replace.zero) :
>  
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
2025 Jan 23
2
Depends: R (>= 4.1) for packages that use |> and \(...)
>>>>> Ivan Krylov via R-devel writes:
Thanks.  I am already looking handling the 4.2.0 placeholder syntax, but
likely will need to refactor the code I added yesterday.
The "experimental" 4.3.0 extra placeholder feature looks like a lot of
effort: ideally there would be a simpler way.  I'll ask on R Core.
My guess would be that the new syntax is particularly
2013 Mar 26
2
when to use which apply function?
Dear list,
I am a little confused as to when to use apply, sapply, tapply, vapply,
replicate.  I've encountered this several times,
This is time, this is what I am working on,
 mat <- matrix(c(seq(from=1, to=10), rnorm(10)), ncol=2)
 a=1; b=5
newfun <- function(x, y, a, b)
{
 x*y+a+b
}
 sapply(i=1:10, newfun(x=mat[i, 1], y=mat[i, 2], a=a, b=b))
Error in match.fun(FUN) : argument
2025 May 26
1
Bug in prettyNum
Thank you,  Marttila  and Ivan,
As the original author of prettyNum() {etc ..},
I will commit such a bug fix to R-devel (and probably port it to
R 4.5.0 patched) quite soon
(but not yet today).
Best regards,
Martin Maechler
>>>>> Ivan Krylov via R-devel 
>>>>>     on Fri, 23 May 2025 17:14:57 +0300 writes:
    > ? Fri, 23 May 2025 11:47:33 +0000
    >
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,