Re: [R] Matrix scalar operation that saves memory?

2023-04-13 Thread Richard O'Keefe
at allows larger things to be done, albeit often much slower. I > also > > note that you can remove some things you are not using and hope garbage > > collection happens soon enough. > > > > -Original Message- > > From: R-help On Behalf Of Shunran Zhang > &g

Re: [R] Matrix scalar operation that saves memory?

2023-04-12 Thread Iago Giné Vázquez
De: R-help de part de Eric Berger Enviat el: dimecres, 12 d’abril de 2023 8:38 Per a: Bert Gunter A/c: R-help Tema: Re: [R] Matrix scalar operation that saves memory? One possibility might be to use Rcpp. An R matrix is stored in contiguous memory, which can be considered

Re: [R] Matrix scalar operation that saves memory?

2023-04-12 Thread Eric Berger
One possibility might be to use Rcpp. An R matrix is stored in contiguous memory, which can be considered as a vector. Define a C++ function which operates on a vector in place, as in the following: library(Rcpp) cppFunction( 'void subtractConst(NumericVector x, double c) { for ( int i = 0; i

Re: [R] Matrix scalar operation that saves memory?

2023-04-11 Thread Bert Gunter
I doubt that R's basic matrix capabilities can handle this, but have a look at the Matrix package, especially if your matrix is some special form. Bert On Tue, Apr 11, 2023, 19:21 Shunran Zhang wrote: > Hi all, > > I am currently working with a quite large matrix that takes 300G of > memory.

Re: [R] Matrix scalar operation that saves memory?

2023-04-11 Thread Shunran Zhang
l 11, 2023 10:21 PM To: r-help@r-project.org Subject: [R] Matrix scalar operation that saves memory? Hi all, I am currently working with a quite large matrix that takes 300G of memory. My computer only has 512G of memory. I would need to do a few arithmetic on it with a scalar value. My current

Re: [R] Matrix scalar operation that saves memory?

2023-04-11 Thread avi.e.gross
also note that you can remove some things you are not using and hope garbage collection happens soon enough. -Original Message- From: R-help On Behalf Of Shunran Zhang Sent: Tuesday, April 11, 2023 10:21 PM To: r-help@r-project.org Subject: [R] Matrix scalar operation that saves memory?

[R] Matrix scalar operation that saves memory?

2023-04-11 Thread Shunran Zhang
Hi all, I am currently working with a quite large matrix that takes 300G of memory. My computer only has 512G of memory. I would need to do a few arithmetic on it with a scalar value. My current code looks like this: mat <- 100 - mat However such code quickly uses up all of the remaining

Re: [R] Matrix::solve() with 1-d arrays -- treating "array" as "numeric"?

2021-04-19 Thread Martin Maechler
> Deepayan Sarkar > on Mon, 19 Apr 2021 09:56:58 +0530 writes: > On Sat, Apr 17, 2021 at 9:08 PM Martin Maechler > wrote: >> >> > Deepayan Sarkar > on Fri, 16 Apr 2021 11:34:20 >> +0530 writes: >> >> > I get what I initially thought was

Re: [R] Matrix::solve() with 1-d arrays -- treating "array" as "numeric"?

2021-04-18 Thread Deepayan Sarkar
On Sat, Apr 17, 2021 at 9:08 PM Martin Maechler wrote: > > > Deepayan Sarkar > > on Fri, 16 Apr 2021 11:34:20 +0530 writes: > > > I get what I initially thought was unexpected behaviour from: > > > x <- tapply(runif(100), sample(5, 100, TRUE), mean) > > solve(Diagonal(5),

Re: [R] Matrix::solve() with 1-d arrays -- treating "array" as "numeric"?

2021-04-17 Thread Martin Maechler
> Deepayan Sarkar > on Fri, 16 Apr 2021 11:34:20 +0530 writes: > I get what I initially thought was unexpected behaviour from: > x <- tapply(runif(100), sample(5, 100, TRUE), mean) > solve(Diagonal(5), x) > # Error: not-yet-implemented method for solve(, ). > #

[R] Matrix::solve() with 1-d arrays

2021-04-16 Thread Deepayan Sarkar
I get what I initially thought was unexpected behaviour from: x <- tapply(runif(100), sample(5, 100, TRUE), mean) solve(Diagonal(5), x) # Error: not-yet-implemented method for solve(, ). # ->> Ask the package authors to implement the missing feature. This is because x is a 1-D array, so the

Re: [R] Matrix - remove [,1] from top row

2019-07-02 Thread Richard O'Keefe
(1) m[,1] is the first column of matrix (or dataframe) m. (2) The first row of matrix or dataframe m is m[1,] (3) To remove the first row of matrix or dataframe m, do m <- m[-1,] On Wed, 3 Jul 2019 at 08:59, Nicola Cecchino wrote: > Hello, > > I am simply trying to remove the [,1] row from

Re: [R] Matrix - remove [,1] from top row

2019-07-02 Thread Richard M. Heiberger
give your a matrix an empty column name. > tmp <- matrix(1:4, 4, 1, dimnames=list(letters[1:4], NULL)) > tmp [,1] a1 b2 c3 d4 > dimnames(tmp)[[1]] [1] "a" "b" "c" "d" > dimnames(tmp)[[2]] NULL > dimnames(tmp)[[2]] <- "" > tmp a 1 b 2 c 3 d 4 On Tue, Jul 2, 2019 at 5:09 PM

Re: [R] Matrix - remove [,1] from top row

2019-07-02 Thread ruipbarradas
Hello, That is not a row, what you seem to have is an object of class "matrix" and when it's printed it prints the column names or [,1] [,2] etc if there aren't any colnames. So your matrix has just one column and 4 rows with rownames 'date', 'Peeps', 'days', 'worn'. Hope this helps,

[R] Matrix - remove [,1] from top row

2019-07-02 Thread Nicola Cecchino
Hello, I am simply trying to remove the [,1] row from a matrix. I tried to search Google to see if I could find how that is removed, but could not find a way to do it. So I have the following: [,1] date 2019-7-01 Peeps 5 days 7 worn 9 this is

Re: [R] Matrix::bdiag doesn't like being given a single named argument

2019-05-31 Thread Jeff Newmiller
My take would be that there is no reason to specify argument names at all when calling bdiag, and clearly there is a reason to not do so. The error seems to arise from using the S3 method is.list, which allows your final example to work. is.list(a=1) clearly fails to match the x argument, but

[R] Matrix::bdiag doesn't like being given a single named argument

2019-05-31 Thread Benjamin Tyner
Hello, Perhaps not a bug, but interesting because the error only happens when there is a single named argument.    > m <- matrix(1, 1, 1)    > library(Matrix)    > bdiag(m)    1 x 1 sparse Matrix of class "dgCMatrix"    [1,] 1    > bdiag(a = m)    Error in is.list(...) : supplied argument

Re: [R] matrix subset problem with factors

2019-02-20 Thread Jeff Newmiller
With on official weight, I second the opinion that the existing behavior is appropriate and not a bug. Functions should not "unexpectedly" return factors... a common example are the read.table family of functions that by default return factors, but the behaviour is deterministic and

Re: [R] matrix subset problem with factors

2019-02-20 Thread Marc Schwartz via R-help
Hi, I get the same behavior in R 3.5.2 on macOS. Others may feel differently, but I am not so sure that this is a bug, as opposed to perhaps the need to clarify in ?Extract, that the following, which is found under Atomic vectors: "The index object i can be numeric, logical, character or

[R] matrix subset problem with factors

2019-02-20 Thread ऋषि / rIsHi
Hi All, I like to report this bug related to matrix subset by rownames when passed as factors. Now factors are may not be safe to use but then it should generate a warning message. Since many time we use values returned by some packages as factor to subset a matrix and which may result in a wrong

Re: [R] Matrix logical operator

2017-07-16 Thread Berend Hasselman
> On 17 Jul 2017, at 07:27, Jeremie Juste wrote: > > > Hello, > > I have some trouble understanding why !b & is TRUE. Do you have an idea? > > >> b <- matrix(c(0,1,1,0,1,0),2) > >> !b > [,1] [,2] [,3] > [1,] TRUE FALSE FALSE > [2,] FALSE TRUE TRUE >> !b &

[R] Matrix logical operator

2017-07-16 Thread Jeremie Juste
Hello, I have some trouble understanding why !b & is TRUE. Do you have an idea? > b <- matrix(c(0,1,1,0,1,0),2) > !b [,1] [,2] [,3] [1,] TRUE FALSE FALSE [2,] FALSE TRUE TRUE > !b & [1] TRUE Best regards, Jeremie __

Re: [R] Matrix multiplication

2017-06-07 Thread Jeff Newmiller
Fine, except that you already seen to have a very compact solution if that really is what you are looking for. What am I missing? -- Sent from my phone. Please excuse my brevity. On June 7, 2017 9:16:48 PM PDT, Steven Yen wrote: >OK Thanks. Your response made me think. Here

Re: [R] Matrix multiplication

2017-06-07 Thread Steven Yen
OK Thanks. Your response made me think. Here (the last line) is what I need: set.seed(76543211) w<-1:10; w a<-matrix(rpois(20,2),nrow=10); a t(w*a)%*%a On 6/8/2017 12:09 PM, Jeff Newmiller wrote: > Is this a question? You seem to have three possible calculations, have > already implemented two

Re: [R] Matrix multiplication

2017-06-07 Thread Jeff Newmiller
Is this a question? You seem to have three possible calculations, have already implemented two of them (?) and it is unclear (to me) what you think the right answer for any of them is supposed to be. -- Sent from my phone. Please excuse my brevity. On June 7, 2017 8:50:55 PM PDT, Steven Yen

[R] Matrix multiplication

2017-06-07 Thread Steven Yen
I need to have all elements of a matrix multiplied by a weight before being post-multiplied by itself, as shown in the forst block of codes below. I can also multiply the matrix by the square root of the weight and then take the outer product. Actually, what I need is this. Denote each row of

Re: [R] Matrix-list table conversion+nrwos with specefic values.

2017-04-29 Thread Jeff Newmiller
le instead of the number of row or number of column of the >matrix. > >Please let me know if this is not clear. > > >Many thanks > > > >From: Jeff Newmiller <jdnew...@dcn.davis.ca.us> >Sent: 29 April 2017 10:11 PM >To: r-help@r-pro

Re: [R] Matrix-list table conversion+nrwos with specefic values.

2017-04-29 Thread Jeff Newmiller
Break it down. If you have a scalar value val and you want to know if it is in a vector vec, using val==vec gets you a logical vector as long as vec. You can use val %in% vec and you get a logical vector as long as val (e.g. 1). If val is a vector of, say, length 2, then you will get a length 2

Re: [R] Matrix-list table conversion+nrwos with specefic values.

2017-04-29 Thread Bert Gunter
I am not a private (or free!) consultant. Post to the r-help if your question concerns R. -- Bert Bert Gunter On Sat, Apr 29, 2017 at 8:51 AM, abo dalash wrote: > Hi dear Bert > > > I'm trying to identify number of rows containing 2 specific values. > > I tried :

Re: [R] matrix merge, or something else?

2017-03-10 Thread Evan Cooch
Slick -- thanks. On 3/10/2017 1:26 AM, Jeff Newmiller wrote: test2[ , colnames( test1 ) ] <- test1 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] matrix merge, or something else?

2017-03-09 Thread Jeff Newmiller
test2[ , colnames( test1 ) ] <- test1 -- Sent from my phone. Please excuse my brevity. On March 9, 2017 6:56:13 PM PST, Evan Cooch wrote: >Suppose I have the following two matrices, both with same number of >rows >(3), but different number of columns (3 in test1, 4 in

[R] matrix merge, or something else?

2017-03-09 Thread Evan Cooch
Suppose I have the following two matrices, both with same number of rows (3), but different number of columns (3 in test1, 4 in test2). test1 <- matrix(c(1,1,0,1,0,-1,-1,-1,0),3,3,byrow=T); test2 <- matrix( rep( 0, len=12), nrow = 3) I label the rows and columns of the two matrices as follows:

Re: [R] Matrix

2017-03-07 Thread David L Carlson
lson Department of Anthropology Texas A University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Gabor Grothendieck Sent: Tuesday, March 7, 2017 7:21 AM To: Peter Thuresson <peter.thures...@umea.se> Cc: R-help@r-project.

Re: [R] Matrix

2017-03-07 Thread Gabor Grothendieck
Assuming that the input is x <- 1:4, try this one-liner: > embed(c(0*x[-1], x, 0*x[-1]), 4) [,1] [,2] [,3] [,4] [1,]1000 [2,]2100 [3,]3210 [4,]4321 [5,]0432 [6,]0043 [7,]0004 On

Re: [R] Matrix

2017-03-06 Thread Richard M. Heiberger
## 1. ## This could be captured into a function tmp <- matrix(0, 7, 4) tmp diag(tmp) <- 1 diag(tmp[-1,]) <- 2 diag(tmp[-(1:2),]) <- 3 diag(tmp[-(1:3),]) <- 4 tmp ## 2. v <- 1:4 v2 <- c(v, rep(0, length(v))) ## this generates a warning that can safely be ignored (or turned off) matrix(v2,

Re: [R] Matrix

2017-03-06 Thread Mathew Guilfoyle
Effectively you want a circulant matrix but filled by column. Example input vector and number of columns x = c(1:8,19:20) nc = 5 For the result you specifically describe, the following generalises for any vector and any arbitrary number of columns 'nc', padding with zeros as necessary.

Re: [R] Matrix

2017-03-06 Thread Bert Gunter
Well, of course, I *did* make a dumb error (again!!). Here's the corrected version: x <- c(1:5,10:12) ## generate vector of indices by outer and %% i <- seq_along(x) nc <- 4 ## number of columns desired Corrected statement indx <- (outer(i, rev(i-1),"+") %% length(x)) [,seq_len(nc)] +1

Re: [R] Matrix

2017-03-06 Thread Bert Gunter
Clever, Don. Here's a more explicit approach that generalizes (if I haven't made any dumb errors): x <- c(1:5,10:12) ## generate vector of indices by outer and %% i <- seq_along(x) nc <- 4 ## number of columns desired ## get subscripting indices via outer() and %% indx <- outer(i,rev(i),"+") %%

Re: [R] Matrix

2017-03-06 Thread Rui Barradas
Hello, Try the following. proj <- function(x){ n <- length(x) y <- numeric(n) z <- rep(c(x, y), times = n) z <- z[-((length(z) - n + 1):length(z))] matrix(z, ncol = n) } proj(1:4) proj(1:5) Hope this helps, Rui Barradas Em 06-03-2017 16:18, Peter

Re: [R] Matrix

2017-03-06 Thread MacQueen, Don
How about this: p0 <- 1:4 matrix( c( rep( c(p0, rep(0, 4)) , times=3) , p0) , 7, 4) Of course, it would take some effort to generalize it to different lengths for p0. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On

[R] Matrix

2017-03-06 Thread Peter Thuresson
Hello, Is there a function in R which can transform, let say a vector: c(1:4) to a matrix where the vector is repeated but "projected" +1 one step down for every (new) column. I want the output below from the vector above, like this:

Re: [R] R matrix multiplication slowdown

2017-01-27 Thread ken eagle
I've done more searching and found a problem with the data in one of the matrices that was corrupting the calculation. Data now fixed and problem is solved. Apologies if anyone wasted time on this. Ken On Fri, Jan 27, 2017 at 8:29 AM, Jeff Newmiller wrote: > You are

Re: [R] R matrix multiplication slowdown

2017-01-27 Thread Jeff Newmiller
You are asked by the Posting Guide to provide a reproducible example and to post in plain text (because HTML gets mangled). I would guess your problem has nothing to do with multiplication, but without the code there is no way to say for sure. -- Sent from my phone. Please excuse my brevity.

[R] R matrix multiplication slowdown

2017-01-27 Thread ken eagle
Hi all. A question about performance of matrix multiplication. I have two relatively large matrices: A is 100x3072, all integers 0-255, not sparse B is 1016x3072, all integers 0-255, not sparse The command z<-B %*% t(A) works fine and takes roughly 0.2 seconds . If I add one row to B,

Re: [R] Matrix

2016-07-17 Thread David Winsemius
> On Jul 16, 2016, at 7:43 PM, Ashta wrote: > > HI Denes, Duncan,Michael and all, > > Thank you very much for the helpful suggestion. Some of my data sets > were not square matrix, however, Denes's suggestion," > as.data.frame.table() ", handled that one. >

Re: [R] Matrix

2016-07-16 Thread Ashta
HI Denes, Duncan,Michael and all, Thank you very much for the helpful suggestion. Some of my data sets were not square matrix, however, Denes's suggestion," as.data.frame.table() ", handled that one. Thank you again. On Sat, Jul 16, 2016 at 7:27 PM, Dénes Tóth wrote:

Re: [R] Matrix

2016-07-16 Thread Dénes Tóth
On 07/17/2016 01:39 AM, Duncan Murdoch wrote: On 16/07/2016 6:25 PM, Ashta wrote: > Hi all, > > I have a large square matrix (60 x 60) and found it hard to > visualize. Is it possible to change it as shown below? > > Sample example (3 x 3) > > A B C > A 3 4 5 > B 4

Re: [R] Matrix

2016-07-16 Thread Michael Hannon
I'm not sure what the OP is looking for in the first two columns, but he does seem to be looking for only the diagonal and super-diagonal elements. Here's some code that makes output that looks similar to the "Desired output": mat1 <- matrix(rbind(c(3, 4, 5), c(4, 7, 8),

Re: [R] Matrix

2016-07-16 Thread Duncan Murdoch
On 16/07/2016 6:25 PM, Ashta wrote: > Hi all, > > I have a large square matrix (60 x 60) and found it hard to > visualize. Is it possible to change it as shown below? > > Sample example (3 x 3) > > A B C > A 3 4 5 > B 4 7 8 > C 5 8 9 > > Desired output > A A 3 > A B 4 >

[R] Matrix

2016-07-16 Thread Ashta
Hi all, I have a large square matrix (60 x 60) and found it hard to visualize. Is it possible to change it as shown below? Sample example (3 x 3) A B C A 3 4 5 B 4 7 8 C 5 8 9 Desired output A A 3 A B 4 A C 5 B B 7 B C 8 C C 9 Thank you in advance

Re: [R] matrix indexing/subset error

2016-05-30 Thread Jeff Newmiller
z %% 2 == 1 has 12 logical values. What do you expect R to do with it worth respect to 4 rows? -- Sent from my phone. Please excuse my brevity. On May 30, 2016 11:38:46 AM PDT, Carl Sutton via R-help wrote: >Hi Guru's >In my quest to understand R I have what I thought

[R] matrix indexing/subset error

2016-05-30 Thread Carl Sutton via R-help
Hi Guru's In my quest to understand R I have what I thought was a simple exercise that now has me baffled.  Why the error message after running this code?  I am totally baffled by the error message.  I was expecting rows 1 and 3 of the x matrix to be returned, and have not a clue as to why this

Re: [R] Matrix multiplications

2016-05-21 Thread george brida
Thank you very much Peter. On Sat, May 21, 2016 at 9:18 PM, peter dalgaard wrote: > > > On 21 May 2016, at 21:00 , george brida wrote: > > > > Dear R users: > > > > I have written the following lines : > > > >>

Re: [R] Matrix multiplications

2016-05-21 Thread peter dalgaard
I don't know if there is some sort of propagation delay, but the reason has already been given and multiple fixes suggested. -pd > On 21 May 2016, at 21:26 , george brida wrote: > > Roy, > > Yes, t(y-X %*% b) is the transpose of y-X %*% b. In principle the product >

Re: [R] Matrix multiplications

2016-05-21 Thread george brida
Roy, Yes, t(y-X %*% b) is the transpose of y-X %*% b. In principle the product of t(y-X %*% b) *(y-X %*% b) is a scalar, I don't know why I have an error message after the following line: (t(y-X %*% b)%*%(y-X %*% b)/(length(y)-ncol(X)))*solve(t(X)%*% X) Thanks On Sat, May 21, 2016 at 9:10

Re: [R] Matrix multiplications

2016-05-21 Thread peter dalgaard
> On 21 May 2016, at 21:00 , george brida wrote: > > Dear R users: > > I have written the following lines : > >> x=c(10,11,12,13,14,17,15,16,10,11,41,25,26,14,12,14,15,20,14,22) >> x=matrix(x,ncol=2) >> a=matrix(1,nrow(x),1) >> X=cbind(a,x) >> y=c(12.00, 11.00, 13.00,

Re: [R] Matrix multiplications

2016-05-21 Thread Roy Mendelssohn - NOAA Federal
> str(t(y-X %*% b)) num [1, 1:10] 0.595 -1.7538 -0.0498 -1.651 -0.6328 ... > str((y-X %*% b)) num [1:10, 1] 0.595 -1.7538 -0.0498 -1.651 -0.6328 … -Roy > On May 21, 2016, at 12:00 PM, george brida wrote: > > Dear R users: > > I have written the following lines : >

[R] Matrix multiplications

2016-05-21 Thread george brida
Dear R users: I have written the following lines : >x=c(10,11,12,13,14,17,15,16,10,11,41,25,26,14,12,14,15,20,14,22) > x=matrix(x,ncol=2) > a=matrix(1,nrow(x),1) > X=cbind(a,x) >y=c(12.00, 11.00, 13.00, 12.50, 14.00, 18.50, 15.00, 12.50, 13.75, 15.00) >b=solve(t(X)%*% X)%*% t(X)%*% y when I

Re: [R] Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?

2016-04-20 Thread Henrik Bengtsson
On Wed, Apr 20, 2016 at 1:25 AM, Martin Maechler wrote: >> Henrik Bengtsson >> on Tue, 19 Apr 2016 14:04:11 -0700 writes: > > > Using the Matrix package, how can I create a row-oriented sparse > > Matrix from scratch

Re: [R] Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?

2016-04-20 Thread Martin Maechler
> Henrik Bengtsson > on Tue, 19 Apr 2016 14:04:11 -0700 writes: > 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

[R] Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?

2016-04-19 Thread Henrik Bengtsson
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

[R] Matrix-free fused lasso

2016-02-16 Thread Antony Lee
Hi, I am looking for an implementation of the fused lasso that allows the predictor matrix to be an "abstract" linear operator, namely the cumulative sum (that is, (X.b)_i = sum(b_k, k=1..i)) (due to the size of the problem, forming the entire matrix is unlikely to be a good approach). Any

Re: [R] Matrix summary

2016-02-12 Thread Jim Lemon
Hi Ashta, Surely you are aware of the "apply" family of functions that return the numbers you want: ashmat<-matrix(c(117,12,13,21,21,32,11,1,65,43,23,7,58,61,78,95 ), nrow=4,byrow=TRUE) apply(ashmat,2,mean) [1] 65.25 37.00 31.25 31.00 apply(ashmat,1,which.max) [1] 1 2 1 4 Jim On Sat, Feb 13,

Re: [R] Matrix summary

2016-02-12 Thread Bert Gunter
Yes, but colMeans, rowMeans, pmax, pmin , etc. are *much* faster. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Feb 12, 2016 at 9:15 PM,

[R] Matrix summary

2016-02-12 Thread Ashta
hi all, I have a square matrix (1000 by 1000), 1. I want calculate mean, min and max values for each column and row. 2, I want pick the coordinate value of the matrix that has the max and min value for each row and column. This an example 4 by 4 square matrix

[R] Matrix of Lists containing numbers and characters

2016-01-25 Thread TJUN KIAT TEO
Here is my sample code TunePar<-matrix(list(Null),2,2) TunePar[[1,1]]=list(subclasses=3,model="gen.ridge") tune=paste(colnames(Temp),Temp,sep="=") tune=paste(tune,collapse=",") However when I type tune This is what I get "subclasses=3,model=1" The text "gen.ridge has been converted to the

Re: [R] Matrix of Lists containing numbers and characters

2016-01-25 Thread PIKAL Petr
TEO > Sent: Monday, January 25, 2016 9:53 AM > To: r-help@r-project.org > Subject: [R] Matrix of Lists containing numbers and characters > > Here is my sample code > > TunePar<-matrix(list(Null),2,2) > > TunePar[[1,1]]=list(subclasses=3,model="gen.ridge") &g

Re: [R] matrix which results singular but at the same time positive definite

2015-12-28 Thread Stefano Sofia
Da: Paul Gilbert [pgilbert...@gmail.com] Inviato: martedì 15 dicembre 2015 15.28 A: Stefano Sofia Cc: r-help@r-project.org; Fox, John; peter dalgaard Oggetto: Re: [R] matrix which results singular but at the same time positive definite Stefano I think in other response to in this thread you got

Re: [R] matrix which results singular but at the same time positive definite

2015-12-15 Thread Paul Gilbert
Stefano I think in other response to in this thread you got the answer to the question you asked, but you may be asking the wrong question. I'm not familiar with the specific papers you mention and you have not provided enough detail about what you are doing, so I am guessing a bit. The term

Re: [R] matrix which results singular but at the same time positive definite

2015-12-14 Thread Stefano Sofia
-project.org Oggetto: RE: [R] matrix which results singular but at the same time positive definite Dear Peter, > -Original Message- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Thursday, December 10, 2015 11:09 AM > To: Stefano Sofia > Cc: Fox, John; r-help@r-projec

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Giorgio Garziano
Decrease the "tol" parameter specified into the "is.non.singular.matrix() call, for example as: m <- matrix(c( 1.904255e-12, -1.904255e-12, -8.238960e-13, -1.240294e-12, -1.904255e-12, 3.637979e-12, 1.364242e-12, 1.818989e-12, -8.238960e-13, 1.364242e-12,

[R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Stefano Sofia
Dear list users, through the "matrixcalc" package I am performing some checks of variance matrices (which must be positive definite). In this example, it happens that the matrix A here reported is singular but positive definite. Is it possible? [,1] [,2] [,3]

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Rolf Turner
On 10/12/15 23:08, Stefano Sofia wrote: Dear list users, through the "matrixcalc" package I am performing some checks of variance matrices (which must be positive definite). In this example, it happens that the matrix A here reported is singular but positive definite. Is it possible?

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Fox, John
Master University Hamilton, Ontario Canada L8S 4M4 Web: socserv.mcmaster.ca/jfox > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Stefano Sofia > Sent: December 10, 2015 5:08 AM > To: r-help@r-project.org > Subject: [R] matrix w

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Stefano Sofia
-- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Stefano Sofia > Sent: December 10, 2015 5:08 AM > To: r-help@r-project.org > Subject: [R] matrix which results singular but at the same time positive > definite > > Dear list users, > through the "ma

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Fox, John
> Best, > John > > - > John Fox, Professor > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > Web: socserv.mcmaster.ca/jfox > > > > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Be

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread peter dalgaard
; - > John Fox, Professor > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > Web: socserv.mcmaster.ca/jfox > > > > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Stefa

Re: [R] matrix which results singular but at the same time positive definite

2015-12-10 Thread Fox, John
Dear Peter, > -Original Message- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Thursday, December 10, 2015 11:09 AM > To: Stefano Sofia > Cc: Fox, John; r-help@r-project.org > Subject: Re: [R] matrix which results singular but at the same time > positiv

Re: [R] Matrix element-by-element multiplication

2015-09-29 Thread Rolf Turner
On 30/09/15 12:49, waddawanna wrote: Hello Steven, It looks like, there is no in-built function that can do GAUSS ".*" element-wise multiplication. Now, if you want to make the desired computations in R, it is actually preatty straightforward. a<-c(1,2,3) b<-matrix(rep(1:9,1),3,3,byrow=TRUE)

Re: [R] Matrix element-by-element multiplication

2015-09-29 Thread David Winsemius
On Sep 29, 2015, at 4:49 PM, waddawanna wrote: > Hello Steven, > > It looks like, there is no in-built function that can do GAUSS ".*" > element-wise multiplication. > Now, if you want to make the desired computations in R, it is actually > preatty straightforward. > >> a<-c(1,2,3) >>

[R] matrix manipulation

2015-07-16 Thread Therneau, Terry M., Ph.D.
This is as much a mathematics as an R question, in the this should be easy but I don't see it category. Assume I have a full rank p by p matrix V (aside: V = (X'X)^{-1} for a particular setup), a p by k matrix B, and I want to complete an orthagonal basis for the space with distance function

Re: [R] matrix manipulation

2015-07-16 Thread Peter Langfelder
Hi Terry, maybe I'm missing something, but why not define a matrix BB = V'B; then t(B) %*% V = t(BB), then your problem reduces to finding A such that t(BB) %*% A = 0? Peter On Thu, Jul 16, 2015 at 10:28 AM, Therneau, Terry M., Ph.D. thern...@mayo.edu wrote: This is as much a mathematics as an

Re: [R] matrix manipulation -solved

2015-07-16 Thread Therneau, Terry M., Ph.D.
Yes it is obvious --- once someone else pointed it out. Thanks for the hint. Terry T. On 07/16/2015 12:52 PM, Peter Langfelder wrote: Hi Terry, maybe I'm missing something, but why not define a matrix BB = V'B; then t(B) %*% V = t(BB), then your problem reduces to finding A such that t(BB)

Re: [R] Matrix Manipulation R

2015-07-04 Thread David Winsemius
On Jul 4, 2015, at 3:09 AM, Alex Kim dumboisveryd...@gmail.com wrote: Hi guys, Suppose I have an extremely large data frame with 2 columns and .5 mil rows. For example, the last 6 rows may look like this: . .. ... 89 100 93 120 95 125 101NA 115

[R] Matrix Manipulation R

2015-07-04 Thread Alex Kim
Hi guys, Suppose I have an extremely large data frame with 2 columns and .5 mil rows. For example, the last 6 rows may look like this: . .. ... 89 100 93 120 95 125 101NA 115NA 123NA 124NA I would like to manipulate this data frame to

[R] Matrix Manipulation R

2015-07-04 Thread Alex Kim
Hi guys, Suppose I have an extremely large data frame with 2 columns and .5 mil rows. For example, the last 6 rows may look like this: . .. ... 89 100 93 120 95 125 101NA 115NA 123NA 124NA I would like to manipulate this data frame to

[R] Matrix Manipulation

2015-07-04 Thread Alex Kim via R-help
Hi guys, Suppose I have an extremely large data frame with 2 columns and .5 mil rows. For example, the last 6 rows may look like this: . .. ... 89 100 93 120 95 125 101NA 115NA 123NA 124NA I would like to manipulate this data frame to

Re: [R] matrix - delete last row - list

2015-07-04 Thread Michael Sumner
Well 'list' in R is pretty naturally the same as R's 'atomic vector' in scads of languages. In R the term needs special care since it's still a 'vector'. 'Degenerate dimension' is probably a helpful phrase for understanding what is happening here. Cheers, Mike On Saturday, July 4, 2015, Rolf

[R] matrix - delete last row - list

2015-07-03 Thread Zander, Joscha
Good day R-community, i just wondered if it is a bug or a feature... When i have a matrix mat with one column and i delete the last row with mat - mat[-nrow(mat),] the result is a list. So my next call mat[10,] will throw an wrong dimension error. The proper call must be: mat -

Re: [R] matrix - delete last row - list

2015-07-03 Thread Sarah Goslee
Hi, On Fri, Jul 3, 2015 at 10:33 AM, Zander, Joscha joscha.zan...@roche.com wrote: Good day R-community, i just wondered if it is a bug or a feature... When i have a matrix mat with one column and i delete the last row with mat - mat[-nrow(mat),] the result is a list. I have no idea how

Re: [R] matrix - delete last row - list

2015-07-03 Thread Marc Schwartz
On Jul 3, 2015, at 9:33 AM, Zander, Joscha joscha.zan...@roche.com wrote: Good day R-community, i just wondered if it is a bug or a feature... When i have a matrix mat with one column and i delete the last row with mat - mat[-nrow(mat),] the result is a list. So my next call

Re: [R] matrix/df help populate NA

2015-06-14 Thread jim holtman
Is this what you want: x1 = structure(list(Subject = c(x1, x2), A = c(1.5, -1.2), B = c(-1.3, + -0.3), C = c(0.4, 0.3), D = c(-0.2, -0.1)), .Names = c(Subject, + A, B, C, D), class = data.frame, row.names = c(NA, + -2L)) x2 = structure(list(Subject = c(x1, x2), A = c(4.3, 2.4), D = c(-2.4, +

Re: [R] matrix/df help populate NA

2015-06-14 Thread Adrian Johnson
Thank you very much. It worked! On Sun, Jun 14, 2015 at 8:00 PM, jim holtman jholt...@gmail.com wrote: Is this what you want: x1 = structure(list(Subject = c(x1, x2), A = c(1.5, -1.2), B = c(-1.3, + -0.3), C = c(0.4, 0.3), D = c(-0.2, -0.1)), .Names = c(Subject, + A, B, C, D), class =

[R] matrix/df help populate NA

2015-06-13 Thread Adrian Johnson
Dear group: I have two data frames. The column names of the two data frame has some common variables but not identical. my aim is to make 2 DFs more uniform by taking union of both colnames For example: I have x1 and x2 matrices: x1 SubjectAB CD 1 x1 1.5 -1.3 0.4 -0.2

Re: [R] matrix/df help populate NA

2015-06-13 Thread Jeff Newmiller
?merge Particularly look at the all argument. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go...

Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread Sergio Fonda
it. John Kane Kingston ON Canada -Original Message- From: sergio.fond...@gmail.com Sent: Fri, 5 Jun 2015 15:06:34 +0200 To: r-help@r-project.org Subject: [R] Matrix of indexes to extract sparse data in dataframe I would like to avoid a for loop to get a vector of data taken

[R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread Sergio Fonda
I would like to avoid a for loop to get a vector of data taken from rows of a data frame for specific columns. An example is the following (I can't apply min to every row of df, this is just an example): c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19)) c1=apply(c0,1,which.min) c1 [1]

Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread John Kane
d1 - apply(c0, 1, min) I think does it. John Kane Kingston ON Canada -Original Message- From: sergio.fond...@gmail.com Sent: Fri, 5 Jun 2015 15:06:34 +0200 To: r-help@r-project.org Subject: [R] Matrix of indexes to extract sparse data in dataframe I would like to avoid

Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread David L Carlson
To: John Kane Cc: R-help Subject: Re: [R] Matrix of indexes to extract sparse data in dataframe Thank you, of course but I can't use that form as I told. My question is about the possibility to enter in a dataframe with a matrix of indices and get the corresponding values Thanks again Il 05/giu

Re: [R] Matrix of indexes to extract sparse data in dataframe

2015-06-05 Thread Sergio Fonda
- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sergio Fonda Sent: Friday, June 5, 2015 8:47 AM To: John Kane Cc: R-help Subject: Re: [R] Matrix of indexes to extract sparse data in dataframe Thank you, of course but I can't use that form as I told. My question is about

  1   2   3   4   5   6   7   8   9   10   >