Displaying 20 results from an estimated 700 matches similar to: "Why was my R process killed spontaneously?"
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
2007 Apr 25
1
for loops
Hello everybody
I'm very new at using R so probably this is a very stupid question.
I have a matrix of "p" columns and I have to calculate for each of them the "two sample t-statistic" and p-value and to save the results into two different vectors.
I have divided my matrix into two submatrices: submatrix A containing the first "n1" rows (p columns) and submatrix B
2012 Oct 22
4
Help with applying a function to all possible 2x2 submatrices
Hi all,
I'm working with a large data set (on the order of 300X300) and trying to
apply a function which compares the elements of all possible 2x2
submatrices. There are rc(r-1)(c-1) such submatrices, so obviously the naive
method of looping through the rows and columns is computationally unfeasible
for my data set:
for(i in 1:(nrow(data)-1)) {
for(j in (i+1):nrow(data)) {
for (m
2002 Feb 01
3
matrix with ncol=1
Hello list,
I try to optimize some R code and it turns out that the function as.matrix
takes a lot of time in my code. There is only one reason why I need
as.matrix: My code should work for matrices with ncol=p and p should be
allowed to be 1 or larger.
Now I have a matrix x with dim(x)=(n,p), and
I need to work with the submatrix y <-x[gv,], (gv a vector of
n logicals) and to calculate
1998 Apr 09
1
0-extent matrices?
Is there a good reason not to allow matrix extents to be zero? I have been
writing a function which fits glms under certain linear constraints. I
fit the model with a reduced set of variables and then transform back to
the original set. This involves operating on submatrices of the
covariance matrix and subsets of the coefficients. Sometimes these subsets
are empty. A zero-length subset of the
2011 Aug 02
1
Functions for Sum of determinants of ranges of matrix subsets
Dear R-help list,
Pls I have this problem. Suppose I have a matrix of size nxn say, generated as follows
z<-matrix(rnorm(n*n,0,1),nrow=n)
I want to write a function such that for i in 1:n, I will remove the rows and columns
corresponding to i (so, will be left with n-1*n-1 submatrix in each cases). Now I need
the sum of the determinant of each of this submatrices. As an example, if n=3, it
2002 Oct 10
2
tapply for matrices
Does anyone have something like tapply that is extremely fast for matrices when there is a very large number of levels of the grouping variable?
I'm referring to, for example,
tapply(x, grouping.variable, function.operating.on.submatrix)
where x is a matrix and the submatrix is a subset of the rows of x. The grouping variable's length equals the number of rows of x.
--
Frank E
2004 Jan 26
3
write.table file="file.txt" help
Hi all,
I have a R script that creates several input files for an analysis
program. It loops through the matrix read into R and picks out
submatrices and then creates a separate output file for each
submatrix. The loop works great, but I am having trouble getting all
the separate output files written.
The line I have is:
write.table(ch1d,
2007 Jul 26
0
Diagonal Submatrices Extraction
Yes you are right ... an example is mandatory.
So ... I have a matrix of 0 with just a single 1 per row and per column
I need to extract all maximal 'diagonal' submatrices
Let's say I have the following matrix
A B C D E
a 0 1 0 0 0
b 1 0 0 0 0
c 0 0 1 0 0
d 0 0 0 1 0
e 0 0 0 0 1
well I would like to get, for this example, the two following submatrices
A B C D E
2011 Apr 27
2
sub-matrix block size
Dear Rxperts
Below is a small vector of values of zeros and non-zeros... was wondering if
there is an efficient way to get the block sizes of submatrices of a big
matrix similar to the one shown below? diagonal elements can be zero too.
Rows with only a diagonal element may be considered as a unit block size.
c(1,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,0,
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:
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 Feb 10
2
Split matrix into square submatices
Hi everybody,
I'm looking for an optimal way to split a big matrix (e.g. ncol = 8,
nrow=8) into small square submatrices (e.g. ncol=2, nrow=2)
For example
If I have
> h
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 1 9 17 25 33 41 49 57
[2,] 2 10 18 26 34 42 50 58
[3,] 3 11 19 27 35 43 51 59
[4,] 4 12 20 28 36
2012 Mar 14
3
Creating 250 submatrices from a large single matrix with 2500 variables using loops
Dear all,
I have a large matrix with about 2500 variables, and 100 rows.
I would like to calculate the means of the every 10 variables starting from
1:2500 and saving the results as a vector or matrix.
How can I do that?
Alternatively, How can I create 250 subset matrices in the order of
variables 1:2500 in groups of 10 from the single matrix which had initially
2500 variables ?
I guess I have
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
2016 Jul 29
2
strange behavior in 'inherits' check for loaded S4 object
I should add one more item that may be related here -- calling
'methods:::.requirePackage' returns a different result based on
whether the package namespace is already loaded or not.
If the package namespace is not loaded, the package is loaded and
attached, and the package environment is returned:
> methods:::.requirePackage("digest")
Loading required package:
2015 Oct 29
2
Extraer elementos diagonales de submatrices
El código que me olvide pegar
input
m <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0,
0, 0, 0, 5, 5, 5), .Dim = c(10L, 5L))
m
## output
output <- c(1:3, 1:5, 1:2)
output
nfilas <- nrow(m)
while(nfilas > 0) {
diagonal <- diag(m)
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
2004 Dec 17
2
Matrix and rownames problem
Hi,
I'm quite new to R, so excuse me if this problem has a simple solution.
I'm working with an array, lets say
i <- array(c(1:3,3:1), dim=c(3,2))
Then I want to give the rows and the columns names:
rownames(i)<-c("a","b","c")
colnames(i)<-c("d","e")
The result is given below:
d e
a 1 3
b 2 2
c 3 1
Here comes my problem.