Displaying 20 results from an estimated 20000 matches similar to: "Matrix and rownames problem"
2012 Jul 15
4
extracting rows and columns from a big matrix
Hi there and thanks in advance.
I have a large symmetrical matrix stored in a text file. After load in R I would like to extract the same number of columns and rows (symmetrical submatrix) using their labels.
I have tried this code in order to extract columns, but R console gives me the "+" sign at the end of the code, pointing out incomplete command, so it is not working:
2011 Apr 13
1
Extracting selected rows from a matrix to a submatix
I have a matrix M
> dim(M)
[1] 30380 561
I have another list L contains , that contains some row names of matrix M
str (L)
chr [1:21037]
Now I want to extract the submatrix subM (21037 , 561) from the matrix M by matching the rownames (M) to the 21037 rownames o f L
How do I do that ?
Thanks and regards,
Pankaj Barah
Pankaj Barah Department of Biology
Norwegian University
2004 Nov 04
3
keep dimension of a sub matrix
Hi,
is there any way to keep a sub matrix dimension?
exemple :
i1<-1; i2<-1
j1<-2; j2<-3;
ret <-matrix(1,4,4)[i1:i2,j1:j2] ;
dim(ret) is NULL because the submatrix single col or single row is coerce to a vector automaticaly.
How can i bypass this cast : submatrix->vector ???????
Thank you.
---------------------------------
[[alternative HTML version
2000 Feb 11
1
Creating efficiently a subset of a matrix
Dear R-helpers
I have the following problem: given a m x n matrix A, I want to have just a
m x k submatrix B, with B[i,] = A[i, offset[i] + 1:k], e.g. from
> offset <- c(0, 0, 1)
> a <- matrix(1:9, 3)
> a
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
the submatrix b
1 4
2 5
6 9
I can do this with a for loop or with sapply
> b <-
2010 Mar 29
4
Confusing concept of vector and matrix in R
Why does R need the concept of "Vector"? In my opinion, it is a useless and
confusing concept. A vector is simply a special case of a matrix whose row
or column number is equal to 1. When I take submatrix from one matrix and
if row or column number is 1, R will automatically convert it into a vector.
It is very straightforward that a submatrix of a matrix should be a matrix.
In
2010 Aug 16
1
Combining values from a data.frame row with matrix rownames.
Hello,
I am trying to iteratively build a build a panel of variables to
discriminate between two groups.
My starting position is a matrix of experimental data and I have a function
that will work through all pairs of variables and produce sensitivities,
specificities and p-values for each pair and write it to a file (above
particular cut-offs).
I have a second function that will read that file
2012 Mar 23
1
Read File for Matrix with rownames
Good morning,
Good morning,
I'm trying to read the file into an array, with the following code.
A<- as.matrix(read.csv("~/Desktop/Results/Cfile.csv", header = FALSE,
sep=","))
The content of the file
" ","1","2","3","4"
"1", 484,43,67,54
"2",54,35,67,34
"3",69,76,78,55
2013 Jan 25
3
Help with adding 'dates' string as rownames to matrix
Hi, I need help with two related issues:
1. I wish to drop repeating text "BST" from the below 'dates' string:
[1] "2005-04-01 BST" "2005-04-04 BST" "2005-04-05 BST" "2005-04-06 BST"
"2005-04-07 BST" "2005-04-08 BST" "2005-04-11 BST" "2005-04-12 BST"
"2005-04-13 BST" "2005-04-14
2004 Feb 09
5
simple question on picking out some rows of a matrix/data frame
Hi,
I have a simple question about matrix/data frame manipulation. I have
a data frame that looks a something like this
X Y Z
1 0 "apples"
-1 -1 "oranges"
...
0 -1 "bananas"
and I'd like to pull out all the rows for which X and Y are (un)equal
into a submatrix.
How can I do that?
Many thanks,
Roger Levy
2007 Oct 15
2
Get data from matrix
Hi,
I have a matrix that has a variable number of columns. I do not know, a
priori, the number of columns.
How can I get a sub matrix, for example, from row 10 to the end of the
columns?
In MatLab I would use something like this: SubMatrix = Matrix[10, 1:end]
Thanks a lot.
--
View this message in context: http://www.nabble.com/Get-data-from-matrix-tf4629336.html#a13218653
Sent from the R
2004 Sep 15
2
efficient submatrix extraction
Hi,
I have a matrix of say 1024x1024 and I want to look at it in chunks.
That is I'd like to divide into a series of submatrices of order 2x2.
| 1 2 3 4 5 6 7 8 ... |
| 1 2 3 4 5 6 7 8 ... |
| 1 2 3 4 5 6 7 8 ... |
| 1 2 3 4 5 6 7 8 ... |
...
So the first submatrix would be
| 1 2 |
| 1 2 |
the second one would be
| 3 4 |
| 3 4 |
and so on. That is I want the matrix to be evenly divided
2016 Jun 25
2
strange behavior in 'inherits' check for loaded S4 object
Hi,
(sorry for the wall of text; the issue here appears to be rather complicated)
I'm seeing a somewhat strange case where checking whether an S4 object
inherits from a parent class defined from another package with
'inherits' fails if that object is materialized through a call to
'load'. That's a mouthful, so I've put together a relatively small
reproducible example
2012 Nov 29
1
Coerce rownames to factor for ordering
Hi all,
I think this might be an easy one but I cannot think of a way to do this
other than what I am currently attempting. I simply want to sort my data
frame's rownames by a defined vector so that the plots I generate from that
vector are in the desired order
Consider the test data below:
#Create test data
DataToPlot.. <- data.frame("Location1" =
2010 Jun 03
2
Matrix subsetting with rownames
Hi,
I have a large matrix containing 10000 rows and 60 columns. I would like to
subset this matrix by using a list of several hundred row names. I tried to
find how to do that, eg with %in% or subset commands, but I never succeed
and I do not find the proper method on internet. How to proceed ?
Thanks
Muppy
--
View this message in context:
2006 Mar 21
1
rownames, colnames, and date and time
I noticed something surprising (in R 2.2.1 on WinXP)
According to the documentation, rownames and colnames are character vectors.
Assigning a vector of class POSIXct or POSIXlt as rownames or colnames
therefore is not strictly according to the rules.
In some cases, R performs a reasonable typecast, but in some other cases
where the same typecast also would be possible, it does not.
Assigning a
2006 Mar 21
1
rownames, colnames, and date and time
I noticed something surprising (in R 2.2.1 on WinXP)
According to the documentation, rownames and colnames are character vectors.
Assigning a vector of class POSIXct or POSIXlt as rownames or colnames
therefore is not strictly according to the rules.
In some cases, R performs a reasonable typecast, but in some other cases
where the same typecast also would be possible, it does not.
Assigning a
2011 Apr 29
1
matrix evaluation using if function
Hi All,
I am trying to create a function which evaluates whether the values (which
are equal to one) of a matrix are the same as their mirror values. Consider
the following matrix:
> n<-matrix(cbind(c(0,1,1),c(1,0,0),c(0,1,0)),3,3)
> colnames(n)<-cbind("A","B","C");rownames(n)<-cbind("A","B","C")
> n
A B C
A 0 1 0
B
2007 May 27
1
How to reference or sort rownames in a data frame
As I was working through elementary examples, I was using dataset
"plasma" of package "HSAUR".
In performing a logistic regression of the data, and making the
diagnostic plots (R-2.5.0)
data(plasma,package='HSAUR')
plasma_1<- glm(ESR ~ fibrinogen * globulin, data=plasma, family=binomial())
layout(matrix(1:4,nrow=2))
plot(plasma_1)
I find that data points
2009 Jul 15
1
problem with merging matrices
Dear all,
I'm a relative new user of R and I have a problem with merging a collection
of matrices. All matrices in this collection have the same dimension (532
rows and 532 columns), but can differ in the row and columns names. I'd like
to merge these matrices in such a way that the resulting matrix only
contains unique row- and column-names and that in case of a match between
the row or
2010 Feb 05
1
Strange "rownames"
I find one row in my large dataset. But when I use the "rownames" for the
data on the 100,000 row, the result show nothing.
I try it by the following example, it still likes that.
> tst[rownames(tst)==100000,]
[1] x y
<0 rows> (or 0-length row.names)
##############
> tst=data.frame(x=1:200000,y=200000:1)
> tst[rownames(tst)==1,]
x y
1 1 200000
>