similar to: as.vector() broken on a matrix or array of type "list"

Displaying 20 results from an estimated 20000 matches similar to: "as.vector() broken on a matrix or array of type "list""

2018 Sep 26
0
as.vector() broken on a matrix or array of type "list"
>>>>> Herv? Pag?s >>>>> on Tue, 25 Sep 2018 23:27:19 -0700 writes: > Hi, Unlike on an atomic matrix, as.vector() doesn't drop > the "dim" attribute of matrix or array of type "list": > m <- matrix(list(), nrow=2, ncol=3) > m > # [,1] [,2] [,3] > # [1,] NULL NULL NULL > # [2,] NULL NULL
2018 Sep 26
1
Stability and reliability of R (comment on Re: as.vector() broken on a matrix or array of type "list")
With regard to Martin's comment about the strength of (base) R: I have R code I wrote 15+ years ago that has been used regularly ever since with only a few minor changes needed due to changes in R. Within that code, I find particularly impressive for its stability a simple custom GUI that uses the tcltk package that has needed no updates whatsoever in all that time. Such stability and
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
Hi, The man page for base::unique.matrix() and base::unique.array() says that MARGIN is expected to be a single integer. OTOH the code in charge of checking the user supplied MARGIN is: if (length(MARGIN) > ndim || any(MARGIN > ndim)) stop(gettextf("MARGIN = %d is invalid for dim = %d", MARGIN, dx), domain = NA) which doesn't really make sense. As
2018 Aug 31
2
Argument 'dim' misspelled in error message
Hi, The following error message misspells the name of the 'dim' argument: > array(integer(0), dim=integer(0)) Error in array(integer(0), dim = integer(0)) : 'dims' cannot be of length 0 The name of the argument is 'dim' not 'dims': > args(array) function (data = NA, dim = length(data), dimnames = NULL) NULL Cheers, H. -- Herv? Pag?s
2017 Jun 06
2
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
Hi, It's nice to be able to define S4 classes with slots that correspond to standard attributes: setClass("A1", slots=c(names="character")) setClass("A2", slots=c(dim="integer")) setClass("A3", slots=c(dimnames="list")) By doing this, one gets a few methods for free: a1 <- new("A1", names=letters[1:3])
2017 Jun 06
1
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
I've fixed this and will commit soon. Disregard my dim<-() example; that behaves as expected (the class needs a dim<-() method). Michael On Tue, Jun 6, 2017 at 5:16 AM, Michael Lawrence <michafla at gene.com> wrote: > Thanks for the report. The issue is that one cannot set special attributes > like names, dim, dimnames, etc on S4 objects. I was aready working on this >
2016 Mar 19
2
unary class union of an S3 class
On 03/19/2016 01:22 AM, Michael Lawrence wrote: > > > On Sat, Mar 19, 2016 at 12:10 AM, Herv? Pag?s <hpages at fredhutch.org > <mailto:hpages at fredhutch.org>> wrote: > > On 03/18/2016 03:28 PM, Michael Lawrence wrote: > > > On Fri, Mar 18, 2016 at 2:53 PM, Herv? Pag?s > <hpages at fredhutch.org <mailto:hpages at
2016 Mar 19
2
unary class union of an S3 class
On 03/18/2016 03:28 PM, Michael Lawrence wrote: > > On Fri, Mar 18, 2016 at 2:53 PM, Herv? Pag?s <hpages at fredhutch.org > <mailto:hpages at fredhutch.org>> wrote: > > Hi, > > Short story > ----------- > > setClassUnion("ArrayLike", "array") > > showClass("ArrayLike") # no slot > >
2018 Jun 08
2
Subsetting the "ROW"s of an object
I suspect this will have suboptimal performance since the TRUEs will get recycled. (Maybe there is, or could be, ALTREP, support for recycling) Hadley On Fri, Jun 8, 2018 at 10:16 AM, Berry, Charles <ccberry at ucsd.edu> wrote: > > >> On Jun 8, 2018, at 8:45 AM, Hadley Wickham <h.wickham at gmail.com> wrote: >> >> Hi all, >> >> Is there a better to
2018 Jun 08
3
Subsetting the "ROW"s of an object
> On Jun 8, 2018, at 10:37 AM, Herv? Pag?s <hpages at fredhutch.org> wrote: > > Also the TRUEs cause problems if some dimensions are 0: > > > matrix(raw(0), nrow=5, ncol=0)[1:3 , TRUE] > Error in matrix(raw(0), nrow = 5, ncol = 0)[1:3, TRUE] : > (subscript) logical subscript too long OK. But this is easy enough to handle. > > H. > > On
2010 Jun 04
2
Argument recycling in substring()
Hi, According to its man page substring() "expands (its) arguments cyclically to the length of the longest _provided_ none are of zero length". So, as expected, I get an error here: > substring("abcd", first=2L, last=integer(0)) Error in substring("abcd", first = 2L, last = integer(0)) : invalid substring argument(s) But I don't get one here:
2014 Oct 24
1
No error when assigning values to an "empty" vector/matrix/array
Assigning one or more values to a vector/matrix/array x for which length(x) == 0 gives no error, e.g. > x <- integer(0) > x[] <- 1:2 > x <- matrix(nrow=0, ncol=1) > x[] <- 1:2 > x[,1] <- 1:2 > x <- array(dim=c(0,1,1)) > x[] <- 1:2 > x[,1,1] <- 1:2 whereas > x <- integer(1) > x[] <- 1:2 Warning message: In x[] <- 1:2 : number of
2018 Jun 08
4
Subsetting the "ROW"s of an object
> On Jun 8, 2018, at 11:52 AM, Hadley Wickham <h.wickham at gmail.com> wrote: > > On Fri, Jun 8, 2018 at 11:38 AM, Berry, Charles <ccberry at ucsd.edu> wrote: >> >> >>> On Jun 8, 2018, at 10:37 AM, Herv? Pag?s <hpages at fredhutch.org> wrote: >>> >>> Also the TRUEs cause problems if some dimensions are 0: >>>
2023 Oct 31
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hi Martin, Henrik, I actually like this change. Makes a lot of sense IMO that dim(x) <- dim(x) be a no-op, or, more generally, that foo(x) <- foo(x) be a no-op for any setter/getter combo. FWIW S4Arrays::set_dim() does that too. It also preserves the dimnames if the right value is only adding or dropping outermost (ineffective) dimensions: ??? > x <- array(1:6, dim=c(2,3,1),
2009 Dec 12
1
cube root on array
Dear R developers, is that right? > -27^(1/3) [1] -3 > c(-27,27)^(1/3) [1] NaN 3 i'm using sign( c(-27,27) ) * abs( c(-27,27)) ^(1/3) , thanks [[alternative HTML version deleted]]
2016 Mar 18
2
unary class union of an S3 class
Hi, Short story ----------- setClassUnion("ArrayLike", "array") showClass("ArrayLike") # no slot setClass("MyArrayLikeConcreteSubclass", contains="ArrayLike", representation(stuff="ANY") ) showClass("MyArrayLikeConcreteSubclass") # 2 slots!! That doesn't seem right. Long story ----------
2017 May 03
2
stopifnot() does not stop at first non-TRUE argument
Not sure why the performance penalty of nonstandard evaluation would be more of a concern here than for something like switch(). If that can't/won't be fixed, what about fixing the man page so it's in sync with the current behavior? Thanks, H. On 05/03/2017 02:26 AM, peter dalgaard wrote: > The first line of stopifnot is > > n <- length(ll <- list(...)) > >
2018 Jun 08
1
Subsetting the "ROW"s of an object
On 06/08/2018 10:15 AM, Michael Lawrence wrote: > There probably should be an abstraction for this. In S4Vectors, we > have extractROWS(). FWIW the code in S4Vectors that does what your subset_ROW() does is: https://github.com/Bioconductor/S4Vectors/blob/04cc9516af986b30445e99fd1337f13321b7b4f6/R/subsetting-utils.R#L466-L476 (This is the default "extractROWS" method.) Except
2019 Mar 22
2
selectMethod() can fail to find methods in situations of multiple dispatch
Fine with me as long as eliminating the inconveniences associated with it can be put on the roadmap. The alias instability and the fact that the user has no way to know if s/he should do ?`foo,numeric-method` or ?`foo,numeric,ANY-method` to find the method has been a long-standing problem. H. On 3/21/19 21:29, Michael Lawrence wrote: If we started over, I'd try to avoid this sort of
2011 Nov 17
1
inaccuracy in man page for duplicated() + anyDuplicated() not working with MARGIN=0
Hi, In man page for duplicated: Value: ?duplicated()?: For a vector input, a logical vector of the same length as ?x?. For a data frame, a logical vector with one element for each row. For a matrix or array, a logical array with the same dimensions and dimnames. When 'x' is a matrix or array, the returned value is NOT a logical array: > m <-