Displaying 20 results from an estimated 3000 matches similar to: "spare matrix replacing values efficiently"
2010 Aug 09
2
efficient matrix element comparison
It is a simple problem in that I simply want to convert the For loop to a more efficient method. It simply loops through a large vector checking if the numeric element is not equal to the index of that element. The following example demonstrates a simplified example:
> rows <- 10
> collusionM <- Matrix(0,10,10,sparse=TRUE)
> matchM <- matrix(c(1,2,3,4,4,6,7,9,9,10))
>
>
2010 Jan 30
2
aggregate by factor
I have a data frame with two columns, a factor and a numeric. I want to create data frame with the factor, its frequency and the median of the numeric column
> head(motifList)
events score
1 aeijm -0.25000000
2 begjm -0.25000000
3 afgjm -0.25000000
4 afhjm -0.25000000
5 aeijm -0.25000000
6 aehjm 0.08333333
To get the frequency table of events:
> motifTable <-
2010 Jan 04
4
function in aggregate applied to specific columns only
I want to use aggregate with the mean function on specific columns
gender <- factor(c("m", "m", "f", "f", "m"))
student <- c(0001, 0002, 0003, 0003, 0001)
score <- c(50, 60, 70, 65, 60)
basicSub <- data.frame(student, gender, score)
basicSubMean <- aggregate(basicSub, by=list(basicSub$student), FUN=mean, na.rm=TRUE)
This
2010 Jun 15
4
shifted window of string
basically I need to create a sliding window in a string. a way to explain this is:
> v <-
2009 Apr 04
2
data.frame, converting row data to columns
I have a data frame something like:
name wrist
nLevel emot
1 4094 3.34 1
frustrated
2 4094 3.94 1
frustrated
3 4094 NA 1
frustrated
4 4094 3.51
2006 Dec 19
1
preserving sparse matrices (Matrix)
Hi,
I have sparse (tridiagonal) matrices, and I use the Matrix package for
handling them. For certain computations, I need to either set the
first row to zero, or double the last row. I find that neither
operation preserves sparsity, eg
> m <- Diagonal(5)
> m
5 x 5 diagonal matrix of class "ddiMatrix"
[,1] [,2] [,3] [,4] [,5]
[1,] 1 . . . .
[2,] . 1
2012 Dec 11
1
Dispatching on a dgCMatrix does not work.
I represent a graph as an adjacency matrix of class "dgCMatrix" (from the Matrix package).
> xx
5 x 5 sparse Matrix of class "dgCMatrix"
a b c d e
a . 1 1 . .
b 1 . 1 . .
c 1 1 . 1 1
d . . 1 . 1
e . . 1 1 .
To check if the matrix defines and undirected graph, I have made the following functions/methods:
is.UG <- function (object) {
UseMethod("is.UG")
}
2009 Jul 20
1
S4 method dispatch with inheritance
Hi,
I'm trying to create a new S4 class (myMatrix) which for now just
extends dgCMatrix (from package Matrix). Then I want to use "[" which is
defined in Matrix.
Out of the box with "[" (defined in Matrix) I lose the class information
and the result is an object of class dgCMatrix. If I specify a
"["-method for myMatrix, it is not used because a signature
2006 Jul 09
1
package:Matrix handling of data with identical indices
In the Matrix package v. 0.995-11 I see that the dgTMatrix
Class for compressed, sparse, triplet-form matrices handles
Identically indexed data instances by summing their values,
e.g.,
library(Matrix)
(Mt <- new("dgTMatrix",
i = as.integer(c(0,0,1,1,4)),
j = as.integer(c(0,1,2,2,4)),
x = as.double(1:5),
Dim = as.integer(c(5,5))))
## 5 x 5 sparse Matrix of class
2006 Jul 09
1
package:Matrix handling of data with identical indices
In the Matrix package v. 0.995-11 I see that the dgTMatrix
Class for compressed, sparse, triplet-form matrices handles
Identically indexed data instances by summing their values,
e.g.,
library(Matrix)
(Mt <- new("dgTMatrix",
i = as.integer(c(0,0,1,1,4)),
j = as.integer(c(0,1,2,2,4)),
x = as.double(1:5),
Dim = as.integer(c(5,5))))
## 5 x 5 sparse Matrix of class
2012 Jul 28
1
Creating sparse matrix of type "dgCMatrix" directly
I want to create a sparse matrix of type "dgCMatrix" using the Matrix package (and the matrix must be of this type even if other more compact representations may exist). I do
> library(Matrix)
> m1<-Matrix(rep(1,4),nrow=2,ncol=2,sparse=T)
> m1
2 x 2 sparse Matrix of class "dsCMatrix"
[1,] 1 1
[2,] 1 1
To convert m1, I do
> as(m1, "dgCMatrix")
2017 Oct 20
0
What exactly is an dgCMatrix-class. There are so many attributes.
Subsetting using [] vs. head(), gives different results.
R code:
> head(train$data, 5)
[1] 0 0 1 0 0
> train$data[1:5, 1:5]
5 x 5 sparse Matrix of class "dgCMatrix"
cap-shape=bell cap-shape=conical cap-shape=convex
[1,] . . 1
[2,] . . 1
[3,] 1 .
2017 Oct 20
0
What exactly is an dgCMatrix-class. There are so many attributes.
> On Oct 20, 2017, at 11:11 AM, C W <tmrsg11 at gmail.com> wrote:
>
> Dear R list,
>
> I came across dgCMatrix. I believe this class is associated with sparse
> matrix.
Yes. See:
help('dgCMatrix-class', pack=Matrix)
If Martin Maechler happens to respond to this you should listen to him rather than anything I write. Much of what the Matrix package does appears
2017 Oct 21
1
What exactly is an dgCMatrix-class. There are so many attributes.
> On Oct 21, 2017, at 7:50 AM, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>
>>>>>> C W <tmrsg11 at gmail.com>
>>>>>> on Fri, 20 Oct 2017 15:51:16 -0400 writes:
>
>> Thank you for your responses. I guess I don't feel
>> alone. I don't find the documentation go into any detail.
>
>> I also find
2016 Apr 19
2
Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?
Using the Matrix package, how can I create a row-oriented sparse
Matrix from scratch populated with some data? By default a
column-oriented one is created and I'm aware of the note that the
package is optimized for column-oriented ones, but I'm only interested
in using it for holding my sparse row-oriented data and doing basic
subsetting by rows (even using drop=FALSE).
Here is what I
2017 Oct 21
0
What exactly is an dgCMatrix-class. There are so many attributes.
>>>>> C W <tmrsg11 at gmail.com>
>>>>> on Fri, 20 Oct 2017 15:51:16 -0400 writes:
> Thank you for your responses. I guess I don't feel
> alone. I don't find the documentation go into any detail.
> I also find it surprising that,
>> object.size(train$data)
> 1730904 bytes
>>
2017 Oct 20
4
What exactly is an dgCMatrix-class. There are so many attributes.
Thank you for your responses.
I guess I don't feel alone. I don't find the documentation go into any
detail.
I also find it surprising that,
> object.size(train$data)
1730904 bytes
> object.size(as.matrix(train$data))
6575016 bytes
the dgCMatrix actually takes less memory, though it *looks* like the
opposite.
Cheers!
On Fri, Oct 20, 2017 at 3:22 PM, David Winsemius
2012 Oct 09
1
converting dgCMatrix to regular matrix
Hi: I've looked around and I must be missing it because it's probably
somewhere. Does someone know how to convert an object of class dgCmatrix
to a regular matrix. I can send someone the data if they need it but it's
too big to include here.
I read the data in using
temp<-readMat("movielens.mat")
where readMat is from the R.matlab package. But the resulting 2 matrices
2008 Jan 30
1
R package Matrix failing to build with R-devel on Ubuntu AMD64
Switched back to R-devel tonight after using R-2.6.1 for awhile and when
I updated my devel packages Matrix installation failed. Not critical for
me but thought I should report it. I am using Ubuntu Gusty AMD64 OS.
Tail of install output and sessionInfo follows. Mark
Loading required package: methods
Loading required package: lattice
Attaching package: 'Matrix'
The
2004 Aug 06
1
YP submission / cURL issue. (icecast 2.0.1 / gentoo)
Karl Heyes wrote:
> The libs that Brendan mentioned are loaded after the start of the
> program, in fact they are referenced when the host name is looked up.
> The loading is done within libc so apps like icecast don't know it's
> being done. ldd does not show these libs, but the mechanism is the same
> as used by plugins of various apps.
Would building statically help? Is