similar to: subsetting a matrix with specified no of columns

Displaying 20 results from an estimated 30000 matches similar to: "subsetting a matrix with specified no of columns"

2019 Jul 13
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
Hi Michael and Abby, So one thing that could happen that would be backwards compatible (with the exception of something that was an error no longer being an error) is head and tail could take vectors of length (dim(x)) rather than integers of length for n, with the default being n=6 being equivalent to n = c(6, dim(x)[2], <...>, dim(x)[k]), at least for the deprecation cycle, if not
2005 Aug 29
2
reexpand a matrix after subsetting
Hi, suppose I have a matrix (or dataframe) as a result from subsetting. mat <- matrix(1:20,ncol=2) mat[c(3,6,9),] <- NA cc <- complete.cases(mat) sub <- mat[cc,,drop=FALSE] sub <- sub * 2 #some caluculations with sub. now I would like to expand sub somehow so row 3,6, and 9 would be filled with NAs but the rest should be in place again. Is there a simple function for this?
2009 Dec 04
2
selective subsetting of a correlation matrix
Dear All, I have a correlation matrix say 'M' (4000x4000) for 4000 genes and I want to subset it to 'N' (190x190) for 190 genes. The list of those 190 genes are in variable 't'. So the idea is to read the names of genes from variable 't' and subset the matrix M accordingly. Any thoughts are welcome! Best Lee [[alternative HTML version deleted]]
2019 Sep 17
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
>>>>> Fox, John >>>>> on Tue, 17 Sep 2019 12:32:13 +0000 writes: > Dear Herve, > Sorry, I should have said "matrices" rather than "data frames" -- brief() has methods for both. > Best, > John > ----------------------------- > John Fox, Professor Emeritus > McMaster University >
2019 Sep 16
5
head.matrix can return 1000s of columns -- limit to n or add new argument?
>>>>> Michael Chirico >>>>> on Sun, 15 Sep 2019 20:52:34 +0800 writes: > Finally read in detail your response Gabe. Looks great, > and I agree it's quite intuitive, as well as agree against > non-recycling. > Once the length(n) == length(dim(x)) behavior is enabled, > I don't think there's any need/desire to have
1999 Oct 13
1
Q: sort a matrix by picking up columns?
Hi, I am wondering how to write a function which sorts a matrix by giving a vector of column numbers. Suppose we have a matrix (or data frame) "Mat" and I want to obtain order(Mat[,1], Mat[,3], Mat[,6,], Mat[,8], Mat[,10], Mat[,13]) in order to sort the matrix by those columns. Is there a way to write a function so that I can give a vector of the column numbers c(1,3,6,8,10,13) and do
2019 Sep 15
0
head.matrix can return 1000s of columns -- limit to n or add new argument?
Finally read in detail your response Gabe. Looks great, and I agree it's quite intuitive, as well as agree against non-recycling. Once the length(n) == length(dim(x)) behavior is enabled, I don't think there's any need/desire to have head() do x[1:6,1:6] anymore. head(x, c(6, 6)) is quite clear for those familiar with head(x, 6), it would seem to me. Mike C On Sat, Jul 13, 2019 at
2019 Sep 16
0
head.matrix can return 1000s of columns -- limit to n or add new argument?
Awesome. Gabe, since you already have a workshopped version, would you like to proceed? Feel free to ping me to review the patch once it's posted. On Mon, Sep 16, 2019 at 3:26 PM Martin Maechler <maechler at stat.math.ethz.ch> wrote: > >>>>> Michael Chirico > >>>>> on Sun, 15 Sep 2019 20:52:34 +0800 writes: > > > Finally read in
2019 Jul 08
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
I think of head() as a standard helper for "glancing" at objects, so I'm sometimes surprised that head() produces massive output: M = matrix(nrow = 10L, ncol = 100000L) print(head(M)) # <- beware, could be a huge print I assume there are lots of backwards-compatibility issues as well as valid use cases for this behavior, so I guess defaulting to M[1:6, 1:6] is out of the
2005 Jun 14
2
Plotting rows (or columns) from a matrix in different graphs, not using "par"
Dear R-users, I would like to ask whether it's possible (for sure it would be), to plot each rows (or columns) in different graphs and in the same figure region without using the function "par" and then struggling around with "axes" and labels etc. Luckily, I would always have "rows + columns = even number" and the same "ylim". The next one could be a
2011 Jul 19
2
Taking all "complete" diagonals of a matrix
Hi R-Help! I am trying to find a nicer way of extracting all the "complete" diagonals of a matrix. I am working with very large matrices that have many more rows than columns. I want to be able to extract each of the diagonals that are as long as the number of columns in the matrix. I have written a rather ugly function that presently does the job. It illustrates what I am trying to
2000 Aug 21
4
Excluding rows from a matrix
Hi I have a matrix (4 x 950) and I want to remove 3 rows, where the values from the first column are 713, 714 and 715. I can select the rows, one by one, with mat[mat$first==713,] mat[mat$first==714,] ... but I'm unable to (i) select the 3 rows at once, (ii) select the matrix excluding those rows. How can I do it ? Thanks EJ
2019 Sep 17
0
head.matrix can return 1000s of columns -- limit to n or add new argument?
Dear Herve, The brief() generic function in the car package does something very similar to that for data frames (and has methods for other classes of objects as well). Best, John ----------------------------- John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: http::/socserv.mcmaster.ca/jfox > On Sep 17, 2019, at 2:52 AM, Pages, Herve <hpages at
2019 Sep 17
0
head.matrix can return 1000s of columns -- limit to n or add new argument?
Dear Herve, Sorry, I should have said "matrices" rather than "data frames" -- brief() has methods for both. Best, John ----------------------------- John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: http::/socserv.mcmaster.ca/jfox > On Sep 17, 2019, at 8:29 AM, Fox, John <jfox at mcmaster.ca> wrote: > > Dear Herve,
2009 May 24
2
Deleting columns from a matrix
useR's, I have a matrix given by the code: mat <- matrix(c(rep(NA,10),1,2,3,4,5,6,7,8,9,10,10,9,8,NA,6,5,4,NA,2,1,rep(NA,10),1,2,3,4,NA,6,7,8,9,10),10,5) This is a 10x5 matrix containing missing values. All columns except the second contain missing values. I want to delete all columns that contain ALL missing values, and in this case, it would be the first and fourth columns. Any column
2010 Jul 06
2
Odd subsetting behaviour
Hello. I've observed some odd behaviour. Most likely, it is already known and explained somewhere, but I can't find an explanation anywhere, so I would appreciate being pointed in the right direction. The issue with the following code is self explanatory: > mat <- matrix(c(c(1,1,1),c(2,2,2)),nrow=3) > mat[,c(1:3%/%2)] [,1] [,2] [1,] 1 1 [2,] 1 1 [3,] 1 1
2019 Oct 18
0
head.matrix can return 1000s of columns -- limit to n or add new argument?
Hi Martin et al. Sorry for not getting back onto this sooner. I've been pretty well buried under travel plus being sick for a bit, but I will be happy to roll up a patch for this, including documentation and put it into a wishlist item. I'll aim to do that at some point next week. Thanks @Martin Maechler <maechler at stat.math.ethz.ch> for engaging with us and being willing to
2010 Mar 05
2
Selecting rows of a matrix based on some condition on the columns
The data set consists of two sets of matrices, as labelled by the columns, T's and C's. > xy x T1 T2 T3 T4 T5 C1 C2 C3 C4 C5 [1,] 50 0.00 0.00 33.75 0.00 0.00 0.00 36.76 0.00 35.26 0.00 [2,] 13 34.41 0.00 0.00 36.64 32.86 34.11 35.80 37.74 0.00 0.00 [3,] 14 35.85 0.00 33.88 36.68 34.88 34.58 0.00 32.75 37.45 0.00 [4,] 33 34.56
2011 Mar 08
1
repeat matrix column within each array third dimension
Hello all, I'm working with a matrix that will have varying dimensions. It will populate an array such that the number of matrix columns will determine the number of 3rd dimension levels of the array. Rows will be the same for both. For this example lets say the array will have 2 columns, but that's not fixed. dim(arr)<-c(dim(mat)[1],2,dim(mat)[2]) I wish to repeat each matrix
2010 Mar 18
2
how to take multiple subsets from a matrix
useR's I have a matrix from which I want to take multiple subsets from, according to a particular scheme I will now describe. The matrix below (mat) is 5x5, and I want to take 9 subsets of it, each of dimension 3x3. The best way to explain what the result should look like is with the following: > dat <- c(3,6,1,9,12,9,2,10,6,5,3,13,1,4,8,9,4,6,10,11,2,7,3,5,10) > miss <-