Displaying 20 results from an estimated 1000 matches similar to: "Coercing elements of a matrix from integer to double"
2006 Jul 02
1
sparse matrix tools
Dear R-Help list:
I'm using the Matrix library to operate on 600 X ~5000 element
unsymmetrical sparse arrays. So far, so good, but if I find I need more
speed or functionality, how hard would it be to utilize other sparse
matrix toolsets from within R, say MUMPS, PARDISO or UMFPACK, that do
not have explicit R interfaces? More information on these is available
here
2008 Jul 10
2
Position in a vector of the last value > n
This shouldn't be hard, but it's just not
coming to me:
Given a vector, e.g.,
v <- c(20, 134, 45, 20, 24, 500, 20, 20, 20)
how can I get the index of the last value in
the vector having a value greater than n, in
this case, greater than 20? I'm looking for
an efficient function I can use on very large
matrices, as the FUN argument in the apply()
command.
Confidentiality
2007 Mar 04
1
Scoping issue?
Hello, The code below is supposed to be a wrapper for matplot to
do columnwise visible comparison of several matrices, but I'm
doing something wrong because I can't access an argument called
'colnum'. I'd be most grateful for some insight.
Thanks,
John Thaden
Little Rock, AR
################################
# mmatplot is a matplot wrapper to compare the same column of
#
2006 Jul 28
1
order() 'decreasing =' argument must be typed in full
## While in R v. 2.3.1 (the mid-July patch for Windows)
## on a Windows XP machine, this call to order() works fine...
order(1:10,decreasing = TRUE)
## [1] 10 9 8 7 6 5 4 3 2 1
## ...however, the argument name 'decreasing'
## must be typed in toto (note the missing 'g'
## in the following):
> order(1:10,decreasin = TRUE)
## Error in order(na.last, decreasing, ...) :
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
2007 Feb 20
1
baseline fitters
I am pretty pleased with baselines I fit to chromatograms using the
runquantile() function in caTools(v1.6) when its probs parameter is
set to 0.2 and its k parameter to ~1/20th of n (e.g., k ~ 225 for n ~
4500, where n is time series length). This ignores occasional low-
side outliers, and, after baseline subtraction, I can re-adjust any
negative values to zero.
But runquantile's
1999 Jun 29
3
S v. 5
Does R, or will R, be integrating the changes to the Chambers/Lucent S
language under their version 5.0? If not already, then when?
John Thaden
Little Rock, Arkansas, USA
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
1999 Jun 23
2
coercing factors to matrix() --> num/char ? --
Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk> wrote:
> Martin Maechler <maechler at stat.math.ethz.ch> writes:
[ snip... ]
> > >From this logic, coercing to a matrix should coerce to character rather
> > than integer/numeric codes.
>
> Hm. I'm not sure there really is much logic in this... Factors are
> sometimes character-like, sometimes
1999 Jun 18
1
Stepwise model selection question
I use the step() function occasionally, and I think I understand its
objective, proper use, and limitations. Now I see stepwise model selection
being used in what seems to be an unusual way, and I wonder if it is right
or wrong. May I describe?
Genetic mapping tries to find where in an animal's genome are genetic
elements that influence a particular physical trait. Say there are 100
2008 Oct 07
3
vectorized sub, gsub, grep, etc.
R pattern-matching and replacement functions are
vectorized: they can operate on vectors of targets.
However, they can only use one pattern and replacement.
Here is code to apply a different pattern and replacement
for every target. My question: can it be done better?
sub2 <- function(pattern, replacement, x) {
len <- length(x)
if (length(pattern) == 1)
pattern <-
2012 Aug 28
4
predict.lm(...,type="terms") question
Hello all,
How do I actually use the output of predict.lm(..., type="terms") to
predict new term values from new response values?
I'm a chromatographer trying to use R (2.15.1) for one of the most
common calculations in that business:
- Given several chromatographic peak areas measured for control
samples containing a molecule at known (increasing) concentrations,
first
2006 Jul 06
1
Warning while subsetting using Matrix package
Hello,
Could someone please explain the following warning while subsetting in
the Matrix package?
Thanks,
John Thaden, PhD
U. Arkansas for Med. Sci.
Little Rock AR USA
> # In the Matrix package...
> library("Matrix")
> # ...I had previously created a sparse matrix in triplet form:
> str(x)
Formal class 'dgTMatrix' [package "Matrix"] with 6 slots
..@ i
2008 Apr 23
1
S4 default for coercing
Something has changed in the S4 default for coercing. Am I now suppose
to use setAs, or is there something else I should do to make this work:
R version 2.7.0 (2008-04-22)
....
> require("methods")
> setClassUnion("OptionalPOSIXct", c("POSIXct", "NULL"))
[1] "OptionalPOSIXct"
> setClass("TSmetax",
2011 Jul 20
3
Coercing Logical array to Numeric array
Dear all,
Coercing a logical vector to a numeric one is easy. The as.numeric function is used. However what do we use when we have a matrix or an array?
Sumona
2006 Nov 29
1
Matrix*vector: coercing sparse to dense matrix for arithmetic
Hi,
I have a sparse Matrix (kronecker product of spline design matrices),
and I need to multiply each row by a number to get another matrix. If
the matrix is A and the numbers are stored in a vector k, with plain
vanilla matrices I would do
A*k
But when using the Matrix package (class of A is "dgCMatrix"), I get
the warning "coercing sparse to dense matrix for arithmetic".
2013 Jan 23
1
problems with coercing a factor to be numeric
Dear R listers,
I am trying to compute the mean of a dummy variable that is encoded as a
factor. However, even though the levels of my factor are 0 - 1, when I
compute the mean (after coercing the factor to be
numeric), R changes 0 into 1 and 1 into yes, thus altering my expected
result.
Please, consider the following working example:
pp <- rep(0:1, 10)
pp <- factor(pp, levels=(0:1),
2013 Feb 08
2
Coercing of types when raising a number to a series of powers
I'm trying to produce a series of powers of a number as follows:
|> 0.05^0:5
[1] 1 2 3 4 5
This is not the result I expected. I guess some kind of coercion happened,
since,
|> class(0.05^0:5)
[1] "integer"
Could anyone explain me what is happening here?
Thanks,
-Sergio.
2008 Dec 11
1
Coercing data into a simple array
I am using acf() to get the autocorrelations of a time series. It works but
I want to then get the autocorrelations into a simple list of numbers.
> x <- acf(price_changes, lag.max = 12,type = "correlation",plot = FALSE)
> x
Autocorrelations of series ‘price_changes’, by lag
0 1 2 3 4 5 6 7 8 9 10
11 12
1.000
2012 Nov 05
1
no method for coercing this S4 class to a vector
all of a sudden, after a SparseM upgrade(?)
I get this error:
> str(z)
Formal class 'matrix.csr' [package "SparseM"] with 4 slots
..@ ra : num [1:85372672] -0.4288 0.0397 0.0104 -0.1843 -0.1203 ...
..@ ja : int [1:85372672] 1 2 3 4 5 6 7 8 9 10 ...
..@ ia : int [1:699777] 1 123 245 367 489 611 733 855 977 1099 ...
..@ dimension: int [1:2] 699776 122