[R] matrix rows to single numeric element

2011-08-04 Thread Wegan, Michael (DNRE)
I have a matrix of 5 columns and 64 rows, let's call it mat1. All values are 1 or 0. I need to take the values of the elements by row and create a single numeric element that can be placed its respective slot in a 64-element list, named list1. For example, mat1[11,1:5] = 0,1,1,0,1 and I must

Re: [R] matrix rows to single numeric element

2011-08-04 Thread R. Michael Weylandt
This seems to work: apply(mat1,1,function(x){paste(x,collapse=)}) The collapse command inside of paste is (I think) the easiest way to combine strings. Michael Weylandt On Thu, Aug 4, 2011 at 5:45 PM, Wegan, Michael (DNRE) weg...@michigan.gov wrote: I have a matrix of 5 columns and

[R] matrix indexing (igraph ?)

2011-08-02 Thread Robinson, David G
I realize that matrix indexing has been addressed in various flavors, but I'm stumped and didn't find anything in the archives. It's not clear if it is an igraph issue or a more general problem. Thanks in advance for your patience. I am using igraph to read a gml file

[R] Matrix operation with apply family functions

2011-07-11 Thread Dimitris.Kapetanakis
Dear all, I am trying to use the apply family functions to improve the efficiency of my code, though it is a bit hard for me to find sometimes the solutions with these functions. The problem that I want to solve is: I have a matrix of replicated random generated data, e.g. if I have two

[R] Matrix 3d plot

2011-07-05 Thread петрович
I have a problem with a 3d plot, suppose we have a matrix like this: v1v2 v3 v4 jan-2010 0.5 0.250.250.3 feb-2010 0.35 0.12 0.120.4 mar-20100.150.250.25 0.1 and i want to plot this matrix in 3d plot where x-axis is

Re: [R] Matrix 3d plot

2011-07-05 Thread Duncan Murdoch
On 05/07/2011 1:36 PM, петрович wrote: I have a problem with a 3d plot, suppose we have a matrix like this: v1v2 v3 v4 jan-2010 0.5 0.250.250.3 feb-2010 0.35 0.12 0.120.4 mar-20100.150.250.25 0.1 and i want to plot

Re: [R] Matrix 3d plot

2011-07-05 Thread David Winsemius
On Jul 5, 2011, at 1:36 PM, петрович wrote: I have a problem with a 3d plot, suppose we have a matrix like this: v1v2 v3 v4 jan-2010 0.5 0.250.250.3 feb-2010 0.35 0.12 0.120.4 mar-20100.150.250.25 0.1 and i want to

[R] matrix problem-replacing pieces of a matrix

2011-06-21 Thread Costis Ghionnis
#Hallo again.. Thank you for your answers. To sum up: #The problem was that we have the matrix m m-matrix(numeric(length=5*4),nrow=5,ncol=4) m # [,1] [,2] [,3] [,4] # [1,]0000 # [2,]0000 # [3,]0000 # [4,]0000 # [5,]00

[R] matrix problem

2011-06-20 Thread Costis Ghionnis
Hallo everyone! I have a problem about creating a matrix... Suppose we have a vector y-c(1,1,1,3,2) and a zero matrix, m ,with nrows=length(y) and ncol=4. The matrix would look like this: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Re: [R] matrix problem

2011-06-20 Thread Sarah Goslee
How about: y - c(1,1,1,3,2) m - matrix(0, nrow=length(y), ncol=4) m[y==1, ] - matrix(1:4, nrow=sum(y == 1), ncol=4, byrow=TRUE) or, depending on your actual problem y - c(1,1,1,3,2) m - matrix(0, nrow=length(y), ncol=4) m[y == 1,] - col(m[y == 1,]) Sarah On Mon, Jun 20, 2011 at 3:54 PM,

Re: [R] matrix problem

2011-06-20 Thread David Winsemius
On Jun 20, 2011, at 3:54 PM, Costis Ghionnis wrote: Hallo everyone! I have a problem about creating a matrix... Suppose we have a vector y-c(1,1,1,3,2) and a zero matrix, m ,with nrows=length(y) and ncol=4. The matrix would look like this: 0 0 0 0 0 0 0 0

[R] Matrix Question

2011-06-02 Thread Ben Ganzfried
Hi, First of all, I would like to introduce myself as I will probably have many questions over the next few weeks and want to thank you guys in advance for your help. I'm a cancer researcher and I need to learn R to complete a few projects. I have an introductory background in Python. My

Re: [R] Matrix Question

2011-06-02 Thread Bill.Venables
for the possibility that your numbers have more than one digit. Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Ganzfried Sent: Friday, 3 June 2011 4:54 AM To: r-help@r-project.org Subject: [R] Matrix Question Hi

[R] matrix not working

2011-05-26 Thread Dat Mai
by columns c and d, but the only outputs are those from column d - some values from column d are NA - column d was created with the code: df$d=rank(df$c, na.last=keep) #--R Code-# item=unique(df$a) n=length(list) r=matrix(data=NA,nrow=n, ncol=n, dimnames=list(PRR1=item, PRR2=item

Re: [R] matrix not working

2011-05-26 Thread Andy Zhu
: [R] matrix not working To: r-help@r-project.org Date: Thursday, May 26, 2011, 12:24 PM Hello All, I'm trying to create a matrix from a dataframe (let's call it df): ..a..b.c.d a   inputs      output b   inputs      output c   inputs      output d   inputs      output e   inputs

Re: [R] matrix not working

2011-05-26 Thread David Winsemius
character, list, and logical. -- david. --- On Thu, 5/26/11, Dat Mai dat.d@gmail.com wrote: From: Dat Mai dat.d@gmail.com Subject: [R] matrix not working To: r-help@r-project.org Date: Thursday, May 26, 2011, 12:24 PM Hello All, I'm trying to create a matrix from a dataframe (let's

Re: [R] matrix not working

2011-05-26 Thread Dat Mai
. -- david. --- On Thu, 5/26/11, Dat Mai dat.d@gmail.com wrote: From: Dat Mai dat.d@gmail.com Subject: [R] matrix not working To: r-help@r-project.org Date: Thursday, May 26, 2011, 12:24 PM Hello All, I'm trying to create a matrix from a dataframe (let's call it df

Re: [R] matrix not working

2011-05-26 Thread Bert Gunter
Subject: [R]  matrix not working To: r-help@r-project.org Date: Thursday, May 26, 2011, 12:24 PM Hello All, I'm trying to create a matrix from a dataframe (let's call it df): ..a..b.c.d a   inputs      output b   inputs      output c   inputs      output d   inputs

Re: [R] matrix Manipulation...

2011-05-25 Thread Jim Silverton
Hello everyone, I have a 2 x 5 matrix: say 0.2 0.3 1 -1 3 0.2. 0.4 5 0.5 -1 I want to replace all the values greater than or equal to 1 with 1 and those less than or equal to 0 with 0. So I should end up with a mtrix looking like: 0.2 0.3 1 0 1 0.2. 0.4 1 0.5 0

Re: [R] matrix Manipulation...

2011-05-25 Thread Sarah Goslee
It's very easy to do in two steps: testmat - matrix(c(.2, .3, 1, -1, 3, .2, .4, 5, .5, -1), byrow=TRUE, nrow=2) testmat [,1] [,2] [,3] [,4] [,5] [1,] 0.2 0.31 -1.03 [2,] 0.2 0.45 0.5 -1 testmat[testmat = 1] - 1 testmat[testmat 0] - 0 testmat [,1] [,2] [,3] [,4]

Re: [R] matrix help (first occurrence of variable in column)

2011-05-19 Thread Michael Denslow
On Wed, May 18, 2011 at 9:49 PM, jim holtman jholt...@gmail.com wrote: Is this what you were after: mdat - matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE, +               dimnames = list(c(T1, T2), +                               c(sp.1, sp.2, sp.3))) mdat   sp.1 sp.2 sp.3 T1    1    

Re: [R] matrix help (first occurrence of variable in column)

2011-05-19 Thread jim holtman
Is this what you are looking for: mdat3 sp.1 sp.2 sp.3 sp.4 sp.5 T110010 T210010 T311100 T410111 # create a matrix of when species first appeared first - apply(mdat3, 2, function(x) (cumsum(x == 1) 0) + 0L) #

[R] matrix help (first occurrence of variable in column)

2011-05-18 Thread Michael Denslow
Dear R help, Apologies for the less than informative subject line. I will do my best to describe my problem. Consider the following matrix: mdat - matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE, dimnames = list(c(T1, T2), c(sp.1, sp.2, sp.3)))

Re: [R] matrix help (first occurrence of variable in column)

2011-05-18 Thread jim holtman
Is this what you were after: mdat - matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE, + dimnames = list(c(T1, T2), + c(sp.1, sp.2, sp.3))) mdat sp.1 sp.2 sp.3 T1101 T2110 # do 'rle' on each column and see if it is

[R] Matrix manipulation in for loop

2011-05-16 Thread clips10
Hi all, I have a problem with getting my code to do what I want! This is the code I have: create.means.one.size-function(nsample,var,nboot){ mat.x-matrix(0,nrow=nboot,ncol=nsample) for(i in 1:nboot){ mat.x[i,]-sample(var,nsample,replace=T) } mean.mat-rep(0,nboot) for(i in

Re: [R] Matrix manipulation in for loop

2011-05-16 Thread jm_jem
hello I think if you try this: for(j in 1: length(nsample)){ MEANS[,]-create.means.one.size(j,var,nboot) } it will work -- View this message in context: http://r.789695.n4.nabble.com/Matrix-manipulation-in-for-loop-tp3525849p3525888.html Sent from the R help mailing list

Re: [R] matrix evaluation using if function

2011-05-01 Thread ivan
Hi, thank you very much, both methods worked perfectly. Regards On Fri, Apr 29, 2011 at 4:17 PM, Berend Hasselman b...@xs4all.nl wrote: David Winsemius wrote: On Apr 29, 2011, at 4:27 AM, ivan wrote: Hi All, I am trying to create a function which evaluates whether the values

[R] matrix evaluation using if function

2011-04-29 Thread ivan
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

Re: [R] matrix evaluation using if function

2011-04-29 Thread David Winsemius
On Apr 29, 2011, at 4:27 AM, ivan wrote: 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)

Re: [R] matrix evaluation using if function

2011-04-29 Thread Berend Hasselman
David Winsemius wrote: On Apr 29, 2011, at 4:27 AM, ivan wrote: 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:

[R] matrix of higher order differences

2011-04-27 Thread Jeroen Ooms
Is there an easy way to turn a vector of length n into an n by n matrix, in which the diagonal equals the vector, the first off diagonal equals the first order differences, the second... etc. I.e. to do this more efficiently: diffmatrix - function(x){ n - length(x); M - diag(x);

Re: [R] matrix of higher order differences

2011-04-27 Thread Hans W Borchers
Jeroen Ooms jeroenooms at gmail.com writes: Is there an easy way to turn a vector of length n into an n by n matrix, in which the diagonal equals the vector, the first off diagonal equals the first order differences, the second... etc. I.e. to do this more efficiently: diffmatrix -

Re: [R] matrix of higher order differences

2011-04-27 Thread David Winsemius
On Apr 27, 2011, at 7:25 AM, Hans W Borchers wrote: Jeroen Ooms jeroenooms at gmail.com writes: Is there an easy way to turn a vector of length n into an n by n matrix, in which the diagonal equals the vector, the first off diagonal equals the first order differences, the second...

Re: [R] matrix of higher order differences

2011-04-27 Thread Petr Savicky
On Wed, Apr 27, 2011 at 11:25:42AM +, Hans W Borchers wrote: Jeroen Ooms jeroenooms at gmail.com writes: Is there an easy way to turn a vector of length n into an n by n matrix, in which the diagonal equals the vector, the first off diagonal equals the first order differences, the

Re: [R] matrix of higher order differences

2011-04-27 Thread Ravi Varadhan
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Petr Savicky Sent: Wednesday, April 27, 2011 11:01 AM To: r-help@r-project.org Subject: Re: [R] matrix of higher order differences On Wed, Apr 27, 2011 at 11:25:42AM +, Hans W Borchers wrote: Jeroen Ooms jeroenooms at gmail.com writes

Re: [R] matrix of higher order differences

2011-04-27 Thread peter dalgaard
@r-project.org Subject: Re: [R] matrix of higher order differences On Wed, Apr 27, 2011 at 11:25:42AM +, Hans W Borchers wrote: Jeroen Ooms jeroenooms at gmail.com writes: Is there an easy way to turn a vector of length n into an n by n matrix, in which the diagonal equals the vector

Re: [R] matrix of higher order differences

2011-04-27 Thread Ravi Varadhan
of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Wednesday, April 27, 2011 4:59 PM To: Ravi Varadhan Cc: R Help Subject: Re: [R] matrix of higher

[R] matrix

2011-04-26 Thread Val
Hi all, Assume I have a matrix xv= [1 0 0 0 0 12, 0 1 0 0 0 10, *0 0 1 0 0 -9,* 0 0 0 1 0 20, * 0 0 0 0 1 -5]* if the last column of xv less than 0 then I want to set zero the entire row. The desired output looks like the following. In this case row 3 and row 5 are set

Re: [R] matrix

2011-04-26 Thread Peter Langfelder
On Tue, Apr 26, 2011 at 2:28 PM, Val valkr...@gmail.com wrote: Hi all, Assume I have a matrix xv=  [1 0 0 0 0 12,      0 1 0 0 0 10,  *    0 0 1 0 0 -9,*      0 0 0 1 0 20,    *  0 0 0 0 1 -5]* if the last column of xv  less than  0 then I want to set zero the entire row. The desired

Re: [R] matrix

2011-04-26 Thread Henrique Dallazuanna
Try this: replace(m, m[,ncol(m)] 0, 0) On Tue, Apr 26, 2011 at 6:28 PM, Val valkr...@gmail.com wrote: Hi all, Assume I have a matrix xv=  [1 0 0 0 0 12,      0 1 0 0 0 10,  *    0 0 1 0 0 -9,*      0 0 0 1 0 20,    *  0 0 0 0 1 -5]* if the last column of xv  less than  0 then I want

[R] Matrix package transpose

2011-04-20 Thread Tobias Abenius
Hi, Since I installed R 2.13 I cannot use the transpose method t on sparse matrices inside my package. Outside the package works. Is there something new that I have to import methods? Can I then import everything from the Matrix package? The problem is that R tries to use t.default which of

Re: [R] Matrix package transpose

2011-04-20 Thread Douglas Bates
On Wed, Apr 20, 2011 at 8:37 AM, Tobias Abenius tobias.aben...@chalmers.se wrote: Since I installed R 2.13 I cannot use the transpose method t on sparse matrices inside my package. Outside the package works. Is there something new that I have to import methods? Can I then import everything

Re: [R] Matrix manipulation

2011-04-02 Thread andrija djurovic
HI, here is another solution: int - sample(1:20,10) int [1] 10 4 5 2 14 17 9 11 16 13 mat-matrix(11:30,ncol=4) mat [,1] [,2] [,3] [,4] [1,] 11 16 21 26 [2,] 12 17 22 27 [3,] 13 18 23 28 [4,] 14 19 24 29 [5,] 15 20 25 30 mat[apply(mat,1,

[R] Matrix manipulation

2011-04-01 Thread Joseph N. Paulson
Hi all! I have a vector, let's say for example int - sample(1:20,10); for now: now I have a matrix... M = m x n where the first column is a feature column and most likely shares at least one of the int (interesting) numbers. I want to extract the rows where int[] = M[,1] I thought:

Re: [R] Matrix manipulation

2011-04-01 Thread Dennis Murphy
Hi: Here' s one approach: int - sample(1:20,10) m - matrix(sample(1:40, 20), nrow = 10) int [1] 7 12 4 6 1 19 17 20 15 5 m [,1] [,2] [1,]9 15 [2,] 23 32 [3,] 40 14 [4,] 19 38 [5,] 286 [6,] 26 18 [7,] 34 22 [8,]7 35 [9,] 213

Re: [R] matrix inverstion

2011-03-29 Thread Petr Savicky
On Mon, Mar 28, 2011 at 04:51:00PM +0200, Rosario Garcia Gil wrote: Hello I have this matrix which I am trying to invert. I get a message about reciprocal condition number, what that does mean? XT_X [,1] [,2] [,3] [,4] [,5] [1,]30021 [2,]0201

[R] matrix inverstion

2011-03-28 Thread Rosario Garcia Gil
Hello I have this matrix which I am trying to invert. I get a message about reciprocal condition number, what that does mean? XT_X [,1] [,2] [,3] [,4] [,5] [1,]30021 [2,]02011 [3,]00211 [4,]21140 [5,]1

Re: [R] matrix inverstion

2011-03-28 Thread Daniel Nordlund
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rosario Garcia Gil Sent: Monday, March 28, 2011 7:51 AM To: r-help@r-project.org Subject: [R] matrix inverstion Hello I have this matrix which I am trying to invert. I get

Re: [R] matrix inverstion

2011-03-28 Thread Ben Bolker
Daniel Nordlund djnordlund at frontier.com writes: On Behalf Of Rosario Garcia Gil I have this matrix which I am trying to invert. I get a message about reciprocal condition number, what that does mean? [snip] Well, it means exactly what the message says. Within the precision of

Re: [R] Matrix building to remove for loops

2011-03-16 Thread Brian Pellerin
Thanks, we're almost there. The 3rd statement needs to satisfy fi_2[r,c]-fi_2[c,r] where rc. On Tue, Mar 15, 2011 at 10:06 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: fi_2 - diag(1, i) fi_2[lower.tri(fi_2)] - 1 - runif(sum(lower.tri(fi_2))) ^ .5 fi_2[upper.tri(fi_2)] -

[R] Matrix building to remove for loops

2011-03-15 Thread Brian Pellerin
Hello R users, I would like to reduce the number of for loops in my code. I build these matrices (5 times). The main diagonal are 1s and the two sides along the main diagonal mirror each other as follows: i-5 fi-matrix(0,nrow=i,ncol=i)#floral inhibition matrix for(r in 1:i){ for(c in 1:i){

Re: [R] Matrix building to remove for loops

2011-03-15 Thread Henrique Dallazuanna
Try this: fi_2 - diag(1, i) fi_2[lower.tri(fi_2)] - 1 - runif(sum(lower.tri(fi_2))) ^ .5 fi_2[upper.tri(fi_2)] - fi_2[lower.tri(fi_2)] On Tue, Mar 15, 2011 at 7:51 PM, Brian Pellerin brianpatrickpelle...@gmail.com wrote: Hello R users, I would like to reduce the number of for loops in my

[R] Matrix Help

2011-02-20 Thread Dmitry Berman
Listers, I have a simple matrix: -- m -c(1:7) m - cbind(m) m [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,] 6 [7,] 7 --- I want to add a second column using: [[alternative HTML version deleted]]

Re: [R] Matrix Help

2011-02-20 Thread Dmitry Berman
On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman ravenb...@gmail.com wrote: Listers, I have a simple matrix: -- m -c(1:7) m - cbind(m) m [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,] 6 [7,] 7 --- I want to add a second

Re: [R] Matrix Help

2011-02-20 Thread David Winsemius
On Feb 20, 2011, at 5:56 PM, Dmitry Berman wrote: On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman ravenb...@gmail.com wrote: Listers, I have a simple matrix: -- m -c(1:7) m - cbind(m) m [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,] 6 [7,] 7

Re: [R] Matrix Help

2011-02-20 Thread Mark Knecht
On Sun, Feb 20, 2011 at 2:56 PM, Dmitry Berman ravenb...@gmail.com wrote: On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman ravenb...@gmail.com wrote: Listers, I have a simple matrix: -- m -c(1:7) m - cbind(m) m [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 [6,]

Re: [R] Matrix in R

2011-02-18 Thread Dieter Menne
danielepippo wrote: I'm building a matrix in R with a cycle for like this: pp_ris2=matrix(NA,6,6) for(i in 0:6){ . R is not like c, indexing starts with 1. Dieter -- View this message in context: http://r.789695.n4.nabble.com/Matrix-in-R-tp3312748p3312764.html Sent from the

Re: [R] Matrix in R

2011-02-18 Thread danielepippo
but if in my function pp_ris2[i,j]=myfunction} must be the indexes 0-0,0-1,0-2,0-3, ? -- View this message in context: http://r.789695.n4.nabble.com/Matrix-in-R-tp3312748p3312780.html Sent from the R help mailing list archive at Nabble.com. __

[R] Matrix in R

2011-02-18 Thread danielepippo
Hi everyone, I'm building a matrix in R with a cycle for like this: pp_ris2=matrix(NA,6,6) for(i in 0:6){ for(j in 0:6){ if(ij){ pp_ris2[i,j]=myfunction} else if(i==j){ print(c(i,j)) pp_ris2[i,j]=myfunction}

Re: [R] Matrix in R

2011-02-18 Thread Philipp Pagel
On Fri, Feb 18, 2011 at 06:32:01AM -0800, danielepippo wrote: but if in my function pp_ris2[i,j]=myfunction} must be the indexes 0-0,0-1,0-2,0-3, ? You'll have to take care of that yourself with a bit of index arithmetics. It's the same you encounter in C, if you are modelling

Re: [R] Matrix in R

2011-02-18 Thread David Winsemius
On Feb 18, 2011, at 9:32 AM, danielepippo wrote: but if in my function pp_ris2[i,j]=myfunction} must be the indexes 0-0,0-1,0-2,0-3, ? From a search of RSiteSearch() that started with with terms: zero matrix indexing http://finzi.psych.upenn.edu/R/Rhelp02/archive/39031.html

Re: [R] Matrix in R

2011-02-18 Thread David Winsemius
On Feb 18, 2011, at 9:32 AM, danielepippo wrote: but if in my function pp_ris2[i,j]=myfunction} must be the indexes 0-0,0-1,0-2,0-3, ? I came across a posting in r-help that called this package blasphemy: http://cran.r-project.org/web/packages/Oarray/index.html -- David Winsemius,

Re: [R] Matrix of Matrices?

2011-02-15 Thread Petr Savicky
On Tue, Feb 15, 2011 at 09:40:54AM -0800, Alaios wrote: Thank you very much for your help again. One more question is that after I have that list of matrices what is the easiest way to find the minimun and maximum values of ALL the matrices in that list? Try the following. # get a list

Re: [R] Matrix of Matrices?

2011-02-11 Thread Petr Savicky
On Thu, Feb 10, 2011 at 11:54:50PM -0800, Alaios wrote: Dear all I have a few matrices that I would like to store alltogether under a bigger object. My matrixes with the same name were calculated inside a loop like for (few times){ estimatedsr- this is my matrix

Re: [R] Matrix of Matrices?

2011-02-11 Thread Alaios
/11/11, Petr Savicky savi...@praha1.ff.cuni.cz wrote: From: Petr Savicky savi...@praha1.ff.cuni.cz Subject: Re: [R] Matrix of Matrices? To: r-help@r-project.org Date: Friday, February 11, 2011, 12:22 PM On Thu, Feb 10, 2011 at 11:54:50PM -0800, Alaios wrote: Dear all I have a few matrices

Re: [R] Matrix of Matrices?

2011-02-11 Thread Petr Savicky
On Fri, Feb 11, 2011 at 06:17:16AM -0800, Alaios wrote: Thanks that did the work. Once I have that list what is the easiest way to export the structure as well as the contents (numbers) into a file. The purpose is to share that file with a colleague and ask him to load that variable with

[R] Matrix of Matrices?

2011-02-10 Thread Alaios
Dear all I have a few matrices that I would like to store alltogether under a bigger object. My matrixes with the same name were calculated inside a loop like for (few times){ estimatedsr- this is my matrix savematrixasimagefile(); } which means that I was losing all that instances.

[R] matrix is not of full rank error in package tgp

2011-02-07 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I want to use the package tgp with its sens() function to cunduct a sensitivity analysis of an ecological simulation model and six independent input parameter. I conducted 10.000 simulations based on a Latin Hypercube design to sample the whole

[R] Unusual slowing of R matrix multiplication version 2.12.1 (2010-10-15) vs 2.12.0

2011-02-07 Thread Joseph Kunkel
R Version 2.12.1 (2010-10-15) vs 2.12.0 has slowed down 8 fold for dual core and 17 fold for dual-core-dual-processor Macs. I have checked this result on 3 different macs using the following R-script: Using Version 2.12.0 on a dual core dual processor Mac:

Re: [R] Unusual slowing of R matrix multiplication version 2.12.1 (2010-10-15) vs 2.12.0

2011-02-07 Thread Prof Brian Ripley
You'll need to ask the person who built R (you haven't told us). If this was a binary CRAN build, you are asked to discuss that only on R-sig-mac, and you will find plenty of discussion on that list's archives. Note that - this is Mac-specific (not mentioned in your subject line) - it even

[R] Matrix' with Functions

2011-02-03 Thread Alaios
Dear R members, I have a quite large of function that are named like that f11,f12,...f15 f21,f22,...f25 .. f51,f52,...f52 These are static (hard-coded) functions that the only common they have is that they take the same number and type of input fij(a,b,c,d). As you might understand this is

Re: [R] Matrix' with Functions

2011-02-03 Thread Claudia Beleites
Seems funny to me: f - list (mean, sd, median, sum) dim (f) - c (2, 2) or in one line: f - structure (.Data=list (mean, sd, median, sum), dim = c(2,2)) f [,1] [,2] [1,] ?? [2,] ?? f [1,1] [[1]] function (x, ...) UseMethod(mean) environment: namespace:base f [[1,1]] (1:3) [1]

Re: [R] Matrix' with Functions

2011-02-03 Thread Samuel Le
2011 16:33 To: R-help@r-project.org Subject: [R] Matrix' with Functions Dear R members, I have a quite large of function that are named like that f11,f12,...f15 f21,f22,...f25 .. f51,f52,...f52 These are static (hard-coded) functions that the only common they have is that they take the same number

Re: [R] Matrix' with Functions

2011-02-03 Thread RICHARD M. HEIBERGER
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: 03 February 2011 16:33 To: R-help@r-project.org Subject: [R] Matrix' with Functions Dear R members, I have a quite large of function that are named like that f11,f12,...f15 f21,f22,...f25

Re: [R] Matrix' with Functions

2011-02-03 Thread Bert Gunter
To: R-help@r-project.org Subject: [R] Matrix' with Functions Dear R members, I have a quite large of function that are named like that f11,f12,...f15 f21,f22,...f25 .. f51,f52,...f52 These are static (hard-coded) functions that the only common they have is that they take the same number

Re: [R] Matrix' with Functions

2011-02-03 Thread Alaios
Dear all, I would like to thank you for your contribution. I think I got more that one good solutions to work on. Best Regards Alex --- On Thu, 2/3/11, Bert Gunter gunter.ber...@gene.com wrote: From: Bert Gunter gunter.ber...@gene.com Subject: Re: [R] Matrix' with Functions To: Samuel Le samuel

[R] matrix and a function - apply function

2011-02-02 Thread ADias
Hi I have this function and this matrix: function(x,y) x+y/x m-matrix(c(1,2,4,2,10,8),3,2) m [,1] [,2] [1,]12 [2,]2 10 [3,]48 each row represent a point (x,y) in a chart and I want via my fucntion to calculate the image in order to get this results: for point

Re: [R] matrix and a function - apply function

2011-02-02 Thread David Winsemius
On Feb 2, 2011, at 9:12 AM, ADias wrote: Hi I have this function and this matrix: function(x,y) x+y/x m-matrix(c(1,2,4,2,10,8),3,2) m [,1] [,2] [1,]12 [2,]2 10 [3,]48 each row represent a point (x,y) in a chart and I want via my fucntion to calculate the

Re: [R] matrix and a function - apply function

2011-02-02 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 02.02.2011 16:05:21: On Feb 2, 2011, at 9:12 AM, ADias wrote: Hi I have this function and this matrix: function(x,y) x+y/x m-matrix(c(1,2,4,2,10,8),3,2) m [,1] [,2] [1,]12 [2,]2 10 [3,]48

Re: [R] matrix and a function - apply function

2011-02-02 Thread Eik Vettorazzi
there is no need for 'apply' here, because R can handle vectors. ord-m[,1]+m[,2]/m[,1] Am 02.02.2011 15:12, schrieb ADias: Hi I have this function and this matrix: function(x,y) x+y/x m-matrix(c(1,2,4,2,10,8),3,2) m [,1] [,2] [1,]12 [2,]2 10 [3,]48

Re: [R] MAtrix addressing

2011-01-26 Thread David Winsemius
If one wants to take an ordinary r matrix and reorder it in the manner you describe: mtx2 - mtx[ nrow(mtx):1, ] Whether that is an efficient way to get at the sokution your you programming task I cannot say. It sounds as though it has gotten too convoluted. I was not able to comprehend

[R] MAtrix addressing

2011-01-25 Thread Alaios
Hello I would like to ask you if it is possible In R Cran to change the default way of addressing a matrix. for example matrix(data=seq(from=1,to=4,nrow=2,ncol=2, by row numbering) # not having R at this pc will create something like the following 1 2 3 4 the way R address this matrix is from

Re: [R] MAtrix addressing

2011-01-25 Thread David Winsemius
On Jan 25, 2011, at 4:50 PM, Alaios wrote: Hello I would like to ask you if it is possible In R Cran to change the default way of addressing a matrix. for example matrix(data=seq(from=1,to=4,nrow=2,ncol=2, by row numbering) # not having R at this pc will create something like the

Re: [R] MAtrix addressing

2011-01-25 Thread Alaios
Regards Alex --- On Wed, 1/26/11, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] MAtrix addressing To: Alaios ala...@yahoo.com Cc: R-help@r-project.org Date: Wednesday, January 26, 2011, 2:54 AM On Jan 25, 2011, at 4:50 PM

Re: [R] matrix manipulations

2011-01-18 Thread Petr Savicky
On Mon, Jan 17, 2011 at 10:37:42PM +, Monica Pisica wrote: Hi, I've got 2 very good solutions, thank you very much. One, from Henrique Dallazuanna using the library reshape and one line of code - although it will take me quite some time to understand it. Here it is what he sent:

[R] matrix manipulations

2011-01-17 Thread Monica Pisica
Hi, I am having some difficulties with matrix operations. It is a little hard to explain it so please bear with me. I have a very large data set, large enough that it needs to be split in parts in order to deal with. I can work things on these parts but the problem lies in adding together

Re: [R] matrix manipulations

2011-01-17 Thread Phil Spector
Monica - Perhaps this small example can demonstrate how factors can solve your problem: d1 = data.frame(cat=sample(c('cat2','cat5','cat6'),100,replace=TRUE),group=sample(c('land','water'),100,replace=TRUE)) d2 =

Re: [R] matrix manipulations

2011-01-17 Thread Henrique Dallazuanna
Try this: library(reshape) xtabs(rowSums(cbind(value.x, value.y), na.rm = TRUE) ~ X1 + X2, merge(melt(m1), melt(m2), by = c('X1', 'X2'), all = TRUE), exclude = FALSE) On Mon, Jan 17, 2011 at 5:59 PM, Monica Pisica pisican...@hotmail.comwrote: Hi, I am having some difficulties with matrix

Re: [R] matrix manipulations

2011-01-17 Thread Monica Pisica
-project.org Subject: Re: [R] matrix manipulations Monica - Perhaps this small example can demonstrate how factors can solve your problem: d1 = data.frame(cat=sample(c('cat2','cat5','cat6'),100,replace=TRUE),group=sample(c('land','water'),100,replace=TRUE)) d2 = data.frame(cat=sample(c

[R] matrix looping accessing previous column

2010-12-27 Thread R_novice
Hi, I have a matrix with numbers and character. I want to evaluate each cell and change the value of the cell before it depending on the evaluation. My evaluation: if a cell had the word down change the cell preceding it to a negative number by multiplying that value by a -1. I am have trouble

Re: [R] matrix looping accessing previous column

2010-12-27 Thread Henrique Dallazuanna
Try this: x V1 V2 V3 V4 1 PROBE 1 2.5 UP 2 PROBE 2 1.0 UP 3 PROBE 3 1.4 DOWN 4 PROBE 4 2.0 UP 5 PROBE 5 1.3 DOWN x$V3[which(x$V4 == DOWN) - 1] - x$V3[which(x$V4 == DOWN) - 1] * -1 On Mon, Dec 27, 2010 at 4:11 PM, R_novice kaso...@battelle.org wrote: Hi, I have a matrix

Re: [R] matrix looping accessing previous column

2010-12-27 Thread R_novice
Thank you for the quick response :-). I've applied your suggestion to my code, but I still receive an error: CEM1_PARTIAL$V3[which(CEM1_PARTIAL$V4 == DOWN) - 1] - CEM1_PARTIAL$V3[which(CEM1_PARTIAL$V4 == DOWN) - 1] * -1 Warning message: In Ops.factor(CEM1_PARTIAL$V3[which(CEM1_PARTIAL$V4 ==

Re: [R] matrix looping accessing previous column

2010-12-27 Thread Henrique Dallazuanna
Convert your column to numeric: CEM1_PARTIAL$V3 - as.numeric(as.character(CEM1_PARTIAL$V3)) On Mon, Dec 27, 2010 at 4:28 PM, R_novice kaso...@battelle.org wrote: Thank you for the quick response :-). I've applied your suggestion to my code, but I still receive an error:

Re: [R] matrix looping accessing previous column

2010-12-27 Thread R_novice
That just converts my values in V3 to NA -- View this message in context: http://r.789695.n4.nabble.com/matrix-looping-accessing-previous-column-tp3165308p3165340.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] matrix looping accessing previous column

2010-12-27 Thread R_novice
Using which() improves my code, but now I'm receiving some data.frame error and still does not convert the values to negative. #TAKE PART OF MATRIX CEM1_PARTIAL - CEM1[1:10,1:10] #CEM1_PARTIAL=apply(CEM1_PARTIAL,2,as.character) #CEM1_PARTIAL - as.numeric(as.character(CEM1_PARTIAL))

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread Liviu Andronic
On Wed, Dec 22, 2010 at 2:57 AM, Phil Spector spec...@stat.berkeley.edu wrote: To make your loop work, you need to learn about the get function. I'm not going to give you the details because there are better approaches available. First, let's make some data that will give values which can be

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread govindas
Thank you both for your suggestions. I have another question - is there a specific way to access the individual elements of a 'list' variable? i.e.  dmi = matrix(rnorm(20),4,5) soi = matrix(rnorm(20),4,5) pe = matrix(rnorm(20),4,5) y - list(dmi, soi, pe) y[[1]]   gives [,1]      

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread Liviu Andronic
On Wed, Dec 22, 2010 at 6:39 PM, govin...@msu.edu wrote: Thank you both for your suggestions. I have another question - is there a specific way to access the individual elements of a 'list' variable? i.e. dmi = matrix(rnorm(20),4,5) soi = matrix(rnorm(20),4,5) pe = matrix(rnorm(20),4,5) y

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread Bert Gunter
Have you consulted R's extensive documentation? -- in particular, An Introduction to R, which would seem like an obvious place for R newbies to start. If you had done so, you would have found your question answered there in section 6.1 on lists. -- Bert Gunter On Wed, Dec 22, 2010 at 9:39 AM,

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread govindas
Thank you all once again .. Yeah, its working now. -- Regards, Mahalakshmi Graduate Student #20, Department of Geography Michigan State University East Lansing, MI 48824 Quoting Liviu Andronic landronim...@gmail.com: On Wed, Dec 22, 2010 at 6:39 PM,  govin...@msu.edu wrote: Thank you both

<    1   2   3   4   5   6   7   8   9   10   >