Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-27 Thread Serguei Sokol
The reason that multi-[column|row] and one-[column|row] matrices should be treated in the same way as to names kept in the result sounds good to me. I withdraw my remark. Serguei. Le 27/11/2018 à 15:48, Radford Neal a écrit : The behaviour of a[1,] is unchanged, for backwards compatibility re

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-27 Thread Radford Neal
> > The behaviour of a[1,] is unchanged, for backwards compatibility > > reasons. But in pqR one can explicitly mark an argument as > > missing using "_". When an array subscript is missing in this way, > > the names will not be dropped in this context even if there is > > only one of them. So a

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-27 Thread Serguei Sokol
Le 27/11/2018 à 01:50, Radford Neal a écrit : Dmitriy Selivanov (selivanov.dmit...@gmail.com) wrote: Consider following example: a = matrix(1:2, nrow = 2, dimnames = list(c("row1", "row2"), c("col1"))) a[1, ] # 1 It returns *unnamed* vector `1` where I would expect named vector. In fact it re

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-26 Thread Radford Neal
Dmitriy Selivanov (selivanov.dmit...@gmail.com) wrote: > Consider following example: > > a = matrix(1:2, nrow = 2, dimnames = list(c("row1", "row2"), c("col1"))) > a[1, ] > # 1 > > It returns *unnamed* vector `1` where I would expect named vector. In fact > it returns named vector when number of c

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-22 Thread Dmitriy Selivanov
Emil, thanks for very nice explanation. Wish base drop would have same behavior as abind::adrop. чт, 22 нояб. 2018 г., 17:47 Emil Bode emil.b...@dans.knaw.nl: > The problem is that the drop is only applied (or not) after the > subsetting, so what R does is: > - Getting the subset, which means a 1

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-22 Thread Serguei Sokol
Le 22/11/2018 à 14:47, Emil Bode a écrit : The problem is that the drop is only applied (or not) after the subsetting, so what R does is: - Getting the subset, which means a 1 x 1 matrix. - Only then It either returns that as is (when drop=FALSE), or removes ALL dimensions of extent 1, regardle

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-22 Thread Emil Bode
The problem is that the drop is only applied (or not) after the subsetting, so what R does is: - Getting the subset, which means a 1 x 1 matrix. - Only then It either returns that as is (when drop=FALSE), or removes ALL dimensions of extent 1, regardless of whether these are rows or columns (or

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-21 Thread Dmitriy Selivanov
Hi Rui. Thanks for answer, I'm aware of drop = FALSE option. Unfortunately it doesn't resolve the issue - I'm expecting to get a vector, not a matrix . ср, 21 нояб. 2018 г. в 20:54, Rui Barradas : > Hello, > > Use drop = FALSE. > > a[1, , drop = FALSE] > # col1 > #row11 > > > Hope this he

Re: [Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-21 Thread Rui Barradas
Hello, Use drop = FALSE. a[1, , drop = FALSE] # col1 #row11 Hope this helps, Rui Barradas Às 16:51 de 21/11/2018, Dmitriy Selivanov escreveu: Hello here. I'm struggling to understand R's subsetting behavior in couple of edge cases - subsetting row in a single column matrix and subse

[Rd] Subsetting row in single column matrix drops names in resulting vector

2018-11-21 Thread Dmitriy Selivanov
Hello here. I'm struggling to understand R's subsetting behavior in couple of edge cases - subsetting row in a single column matrix and subsetting column in a single row matrix. I've read R's docs several times and haven't found answer. Consider following example: a = matrix(1:2, nrow = 2, dimnam