[R] matrix question

2008-08-19 Thread Altaweel, Mark R.
Hi, I have a vector and a list, with data I would like to multiply together. So for instance I have a vector s: [[1]] [1] 44308 [[2]] [1] 4371 Also, I have a list d: [[1]] [1] 1201 6170 2036 2927 1625 1391 2074 1453 3172 3027 4691 3719 1185 320 2071 1027 1046 1186 1403 580 1382 4408

Re: [R] matrix question

2008-08-19 Thread Rolf Turner
On 20/08/2008, at 10:08 AM, Altaweel, Mark R. wrote: Hi, I have a vector and a list, with data I would like to multiply together. No you haven't. You have two ***lists***. Lists and vectors are not the same thing. If you don't distinguish between them you will

Re: [R] matrix row product and cumulative product

2008-08-18 Thread Moshe Olshansky
needed to multiply N pairs of numbers. --- On Mon, 18/8/08, Jeff Laake [EMAIL PROTECTED] wrote: From: Jeff Laake [EMAIL PROTECTED] Subject: [R] matrix row product and cumulative product To: r-help@r-project.org Received: Monday, 18 August, 2008, 12:49 PM I spent a lot of time searching

Re: [R] matrix row product and cumulative product

2008-08-18 Thread Jeff Laake
Thanks for the tips on inline, jit and Reduce. The latter was exactly what I wanted although the loop is still the fastest for the simple product (accumulate=TRUE for reduce). With regards to Moshe's comment, I was just surprised by the timing difference. I tend to use apply without giving

Re: [R] matrix row product and cumulative product

2008-08-18 Thread Jeff Laake
Sorry a correction to my last posting. I had accumulate switched between prod and cumprod and I had also forgotten to included time for conversion from list back to matrix for cumprod. Now as Chuck stated the results for Reduce are about the same or worse than a loop. regards--jeff

[R] matrix row product and cumulative product

2008-08-17 Thread Jeff Laake
I spent a lot of time searching and came up empty handed on the following query. Is there an equivalent to rowSums that does product or cumulative product and avoids use of apply or looping? I found a rowProd in a package but it was a convenience function for apply. As part of a likelihood

Re: [R] matrix row product and cumulative product

2008-08-17 Thread Charles C. Berry
On Sun, 17 Aug 2008, Jeff Laake wrote: I spent a lot of time searching and came up empty handed on the following query. Is there an equivalent to rowSums that does product or cumulative product and avoids use of apply or looping? I found a rowProd in a package but it was a convenience

Re: [R] Matrix multiplication

2008-08-07 Thread Zhang Yanwei - Princeton-MRAm
:42 PM To: Zhang Yanwei - Princeton-MRAm; r-help@r-project.org Subject: RE: [R] Matrix multiplication Hi, Yes. this is a way, and relatively easy ... Using Reduce. Note: in order to use Reduce, you need an update-to-date version of R. I'm using 2.6.2. First you have to have all the matrices line

Re: [R] Matrix multiplication

2008-08-06 Thread Ling, Gary (Electronic Trading)
-5.834807 ### end demo ### So, they are the same. Cheers! -gary -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zhang Yanwei - Princeton-MRAm Sent: Wednesday, August 06, 2008 5:02 PM To: r-help@r-project.org Subject: [R] Matrix multiplication Hi all

[R] Matrix barplot

2008-07-25 Thread Andreas Tille
Hi, as a bloody R beginner I failed to solve the probably simple problem to create a barplot of the following data read from a file Year A BC 2000 4 30 2001 2 13 2002 1 25 The Barplot should look like 5 |

Re: [R] Matrix barplot

2008-07-25 Thread Andreas Tille
On Fri, 25 Jul 2008, Nutter, Benjamin wrote: data - data.frame(Year=c(2000,2001,2002), A=c(4,2,1), B=c(3,1,2), C=c(0,3,5)) data.mat - as.matrix(data)[,2:4] rownames(data.mat) - data$Year data.mat - t(data.mat)

Re: [R] Matrix barplot

2008-07-25 Thread ajay ohri
As a beginner also try downloading the rattle GUI , with all dependecies =true , or R Cmdr GUI.. these are both packages go to rattle.togaware.com for the rattle instructions and installations .its very very user friendly even though the purists think its infra dig.(kidding- Friday humour)

Re: [R] Matrix barplot

2008-07-25 Thread Andreas Tille
On Fri, 25 Jul 2008, Jim Lemon wrote: library(plotrix) Well, if I try this in the example of the previous poster I get nicely rendered fonts - which is the only difference I noticed. # barp groups data in columns, not rows, so transpose barp(t(atdat[,2:4]),names.arg=atdat[,1],col=2:4)

Re: [R] Matrix barplot

2008-07-25 Thread Andreas Tille
,beside=TRUE) As I said this works great - but now I would like to use the table heading as legend - and have no idea how to access the header (see below) -Original Message- On Behalf Of Andreas Tille Sent: Friday, July 25, 2008 8:14 AM To: r-help@r-project.org Subject: [R] Matrix barplot

Re: [R] Matrix from List

2008-07-25 Thread jim holtman
This gets you close to what you want. The 31/33 are row names that you can extract and store as actual columns, x - list('1995'=list('31'=1, '33'=2), '2006'=list('31'=3, '33'=4)) y - lapply(names(x), function(.L1){ + cbind(as.numeric(.L1),do.call(rbind, x[[.L1]])) + }) (z - do.call(rbind,

Re: [R] matrix multiplication question

2008-07-18 Thread Tsjerk Wassenaar
Hi Murali, So, the solution to your problem will be to explicitly convert your matrix to a numeric matrix. Maybe matrix (?matrix) will do, or you'll also have to use as.numeric (?as.numeric). The strings on the left seem to me to be the row labels, right..?, not elements in the matrix/table. As

Re: [R] matrix multiplication question

2008-07-18 Thread Doran, Harold
it exists). -Original Message- From: [EMAIL PROTECTED] on behalf of Duncan Murdoch Sent: Fri 7/18/2008 1:00 AM To: Murali K Cc: r-help@r-project.org Subject: Re: [R] matrix multiplication question On 17/07/2008 9:47 PM, Murali K wrote: Hello, I am a newcomer to R and therefore

[R] matrix multiplication question

2008-07-17 Thread Murali K
Hello, I am a newcomer to R and therefore apologize for posting such a basic question. I am trying to multiply 2 matrices t(X1)%*%X1, where t(X1) is: 1 2 3 4 5 8 12 13 20 24 26 27 31 33 34 36 37 40 41 42 45 46 47 48 49 ones 1 1 1 1 1 1 1 1 1 11 1 1

Re: [R] matrix multiplication question

2008-07-17 Thread Duncan Murdoch
On 17/07/2008 9:47 PM, Murali K wrote: Hello, I am a newcomer to R and therefore apologize for posting such a basic question. I am trying to multiply 2 matrices t(X1)%*%X1, where t(X1) is: It's hard to say for sure, but it looks as though X1 really isn't a numeric matrix. The ones

[R] Matrix set value problem

2008-07-03 Thread Valentino Botta
the following code: m-matrix(nrow=10,ncol=10) i-1001 mx-trunc(i/1000) my-(i/1000-mx)*1000 m[mx,my]-1 does not assign the value at the matrix m[1,1] Any hints? Thanks v -- View this message in context: http://www.nabble.com/Matrix-set-value-problem-tp18253809p18253809.html Sent from the R

Re: [R] Matrix set value problem

2008-07-03 Thread ONKELINX, Thierry
-project.org Onderwerp: [R] Matrix set value problem the following code: m-matrix(nrow=10,ncol=10) i-1001 mx-trunc(i/1000) my-(i/1000-mx)*1000 m[mx,my]-1 does not assign the value at the matrix m[1,1] Any hints? Thanks v -- View this message in context: http://www.nabble.com/Matrix-set-value

Re: [R] Matrix set value problem

2008-07-03 Thread ctu
Hi, when you do the trunc the mx is not a real integer 1 so you must round up m-matrix(data=NA, nrow=10,ncol=10) i-1001 mx-round(trunc(i/1000)) my-round((i/1000-mx)*1000) m[mx,my]-1 m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]1 NA NA NA NA NA NA NA NA

[R] matrix

2008-06-18 Thread Paul Adams
Hello everyone,I am having a difficult time understanding what commands are used to add and remove elements froma matrix or data frame.For ex ample if I want to remove element=[1,50] or elements [1,50:63] or elements  [2:4,20:35]from a matrix and replace with NA or any number what command must

Re: [R] matrix

2008-06-18 Thread Uwe Ligges
Read the help page or better the manuals! And before posting, please read the posting guide. You get the help page for indexing by, e.g.: help([) Uwe Ligges Paul Adams wrote: Hello everyone,I am having a difficult time understanding what commands are used to add and remove elements

[R] Matrix transformation problem

2008-06-11 Thread stefan . petersson
ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y). Sometimes, the matrix is quite large, so I

Re: [R] Matrix transformation problem

2008-06-11 Thread Dimitris Rizopoulos
: [R] Matrix transformation problem ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y

Re: [R] Matrix transformation problem

2008-06-11 Thread Dimitris Rizopoulos
11, 2008 10:10 AM Subject: [R] Matrix transformation problem ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column

Re: [R] Matrix transformation problem

2008-06-11 Thread Eik Vettorazzi
you may try a matrix multiplication, which has a very high performance in R x%*%1:ncol(x) hth. [EMAIL PROTECTED] schrieb: ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the

Re: [R] Matrix transformation problem

2008-06-11 Thread Ted Harding
, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: [EMAIL PROTECTED] To: r-help@r-project.org Sent: Wednesday, June 11, 2008 10:10 AM Subject: [R

Re: [R] Matrix transformation problem

2008-06-11 Thread Berend Hasselman
stefan.petersson wrote: ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y). Sometimes,

[R] Matrix of data frames

2008-06-05 Thread tolga . i . uzuner
Dear R-Users, Is there a way to create a matrix of data frames in R ? I am pulling in data frames from a SQL database into R using RODBC. I would like to pull in a sequence of data frames which are indexed across two dimensions, and store each data frame as an element in a matrix. I did try

Re: [R] Matrix of data frames

2008-06-05 Thread Gabor Grothendieck
On Thu, Jun 5, 2008 at 4:22 PM, [EMAIL PROTECTED] wrote: Dear R-Users, Is there a way to create a matrix of data frames in R ? Using builtin BOD and women: m - matrix(list(BOD, women, women, BOD), 2) m[[1,2]] # women height weight 1 58115 2 59117 3 60120 4

Re: [R] matrix from list

2008-04-28 Thread Kenn Konstabel
it is not obvious what to return without giving extra information, it is better to require the extra information through other functions. From: [EMAIL PROTECTED] on behalf of Olivier Lefevre Sent: Sat 4/26/2008 9:43 AM To: [EMAIL PROTECTED] Subject: Re: [R] matrix

Re: [R] matrix from list

2008-04-28 Thread Prof Brian Ripley
giving extra information, it is better to require the extra information through other functions. From: [EMAIL PROTECTED] on behalf of Olivier Lefevre Sent: Sat 4/26/2008 9:43 AM To: [EMAIL PROTECTED] Subject: Re: [R] matrix from list Olivier Lefevre wrote

Re: [R] matrix from list

2008-04-27 Thread Olivier Lefevre
It's true one may have to set some rules but I think you are blowing it up. First, it is true one would have to agree for list[[vec]] to always return a matrix but it is the useful behaviour since you can already get a vector with unlist(list[vec]). Second, as to the raggedness, matrix(),

Re: [R] matrix from list

2008-04-26 Thread Martin Maechler
OL == Olivier Lefevre [EMAIL PROTECTED] on Sat, 26 Apr 2008 01:31:16 +0200 writes: OL Greg Snow wrote: The '[[' only returns a single element from a data structure OL I know but that is precisely what I find arbitrary. OL Anyway you are right that it would still return

Re: [R] matrix from list

2008-04-26 Thread Olivier Lefevre
Olivier Lefevre wrote: Anyway you are right that it would still return the kind of object, only subsetted, which is not I want. I mean [] would do that; I know [[]] doesn't. Yet I still don't see why one accepts vector arguments but not the other: they are both indexing operators. It is such

Re: [R] matrix from list

2008-04-26 Thread Olivier Lefevre
Martin Maechler wrote: The difference to as.matrix() is that data.matrix() also produces a numeric matrix in the case the data frame contains factors. Thanks, that is useful but it is becoming a little rococo: so may ways to do this. Also, what if I have a list, not a data frame?

Re: [R] matrix from list

2008-04-26 Thread Greg Snow
. From: [EMAIL PROTECTED] on behalf of Olivier Lefevre Sent: Sat 4/26/2008 9:43 AM To: [EMAIL PROTECTED] Subject: Re: [R] matrix from list Olivier Lefevre wrote: Anyway you are right that it would still return the kind of object, only subsetted, which is not I

Re: [R] matrix from list

2008-04-25 Thread Greg Snow
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Olivier Lefevre Sent: Thursday, April 24, 2008 4:16 PM To: [EMAIL PROTECTED] Subject: Re: [R] matrix from list Yes, unlist is the magic wand I was looking for. Thanks a million! Having said

Re: [R] matrix from list

2008-04-25 Thread Olivier Lefevre
Greg Snow wrote: The '[[' only returns a single element from a data structure I know but that is precisely what I find arbitrary. Anyway you are right that it would still return the kind of object, only subsetted, which is not I want. As someone kindly pointed out to me offline, besides the

[R] matrix from list

2008-04-24 Thread Olivier Lefevre
Another possibly simple thing that I cannot get right is how to extract the data part of a list as a matrix. The data were read from xls, with labels, and thus are of list mode, e.g., col1 col2 1 0.1 1.1 2 0.2 1.2 I want to extract from that just the numeric data part, i.e., (in this

Re: [R] matrix from list

2008-04-24 Thread Jorge Ivan Velez
Hi Olivier, is this what you want? x=col1 col2 1 0.1 1.1 2 0.2 1.2 m=read.table(textConnection(x),header=TRUE) m1=matrix(unlist(m),ncol=2) m1 [,1] [,2] [1,] 0.1 1.1 [2,] 0.2 1.2 HTH, Jorge On Thu, Apr 24, 2008 at 6:02 PM, Olivier Lefevre [EMAIL PROTECTED] wrote: Another possibly

Re: [R] matrix from list

2008-04-24 Thread Olivier Lefevre
Yes, unlist is the magic wand I was looking for. Thanks a million! Having said that, I find it rather arbitrary that you can write mat[1:4] but not list[[1:2]]; IMO there should be no need for a magic operator like unlist: list[[1:length(list)]] could do the job. -- O.L.

[R] matrix problem

2008-04-21 Thread William Simpson
Hi Everyone, I am running into a problem with matrices. I use R version 2.4.1 and an older version. The problem is this: m-matrix(ncol=3,nrow=4) m[,1:3]-runif(n=4) That does what I expect; it fills up the rows of the matrix with the data vector m [,1] [,2] [,3] [1,]

Re: [R] matrix problem

2008-04-21 Thread Chuck Cleland
On 4/21/2008 5:54 AM, William Simpson wrote: Hi Everyone, I am running into a problem with matrices. I use R version 2.4.1 and an older version. The problem is this: m-matrix(ncol=3,nrow=4) m[,1:3]-runif(n=4) That does what I expect; it fills up the rows of the matrix with the data

Re: [R] matrix problem

2008-04-21 Thread Rolf Turner
On 21/04/2008, at 9:54 PM, William Simpson wrote: Hi Everyone, I am running into a problem with matrices. I use R version 2.4.1 and an older version. The problem is this: m-matrix(ncol=3,nrow=4) m[,1:3]-runif(n=4) That does what I expect; it fills up the rows of the matrix with the

Re: [R] matrix problem

2008-04-21 Thread William Simpson
Thanks very much Petr and Rold for your helpful replies. Cheers Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,

[R] Matrix Indexing

2008-04-12 Thread Rory Winston
Hi Does anyone know how I might pick out diagonal elements of a matrix using a vector? If I create a matrix a: a - matrix(c(1:16), 4, byrow=TRUE) and I want to pick out the elements (1,1),(2,2),(3,3), or another arbitrary diagonal (upper or lower), is there any way I can use a vector to do

Re: [R] Matrix Indexing

2008-04-12 Thread Chuck Cleland
On 4/12/2008 5:56 AM, Rory Winston wrote: Hi Does anyone know how I might pick out diagonal elements of a matrix using a vector? If I create a matrix a: a - matrix(c(1:16), 4, byrow=TRUE) and I want to pick out the elements (1,1),(2,2),(3,3), or another arbitrary diagonal (upper or

Re: [R] Matrix Indexing

2008-04-12 Thread Gavin Simpson
On Sat, 2008-04-12 at 10:56 +0100, Rory Winston wrote: Hi Does anyone know how I might pick out diagonal elements of a matrix using a vector? If I create a matrix a: a - matrix(c(1:16), 4, byrow=TRUE) Not sure if this does all that you describe below, but: diag(a) and you can subset

Re: [R] Matrix Indexing

2008-04-12 Thread Duncan Murdoch
Rory Winston wrote: Hi Does anyone know how I might pick out diagonal elements of a matrix using a vector? If I create a matrix a: a - matrix(c(1:16), 4, byrow=TRUE) and I want to pick out the elements (1,1),(2,2),(3,3), or another arbitrary diagonal (upper or lower), is there any way I

[R] Matrix Row name Compatibility

2008-03-09 Thread Charles Willis
Hello, I am trying to preform a comparative analysis using the partial mantel method. However, i am having trouble creating compatible matrices. I can create matrices from my numerical data using the 'distance(x, method)' function from ecodist, but the row/column names are out put as numbers.

[R] matrix inversion using solve() and matrices containing large/small values

2008-03-05 Thread gerardus vanneste
Hello I've stumbled upon a problem for inversion of a matrix with large values, and I haven't found a solution yet... I wondered if someone could give a hand. (It is about automatic optimisation of a calibration process, which involves the inverse of the information matrix) code:

Re: [R] matrix inversion using solve() and matrices containing large/small values

2008-03-05 Thread Duncan Murdoch
On 3/5/2008 8:21 AM, gerardus vanneste wrote: Hello I've stumbled upon a problem for inversion of a matrix with large values, and I haven't found a solution yet... I wondered if someone could give a hand. (It is about automatic optimisation of a calibration process, which involves the

Re: [R] matrix inversion using solve() and matrices containing large/small values

2008-03-05 Thread Charilaos Skiadas
Sorry, I meant to send this to the whole list. On Mar 5, 2008, at 8:46 AM, Charilaos Skiadas wrote: The problem doesn't necessarily have to do with the range of data. At first level, it has to do with the simple fact that dfdb has rank 6 at most, (7 at most in general, though in your case

Re: [R] matrix inversion using solve() and matrices containing large/small values

2008-03-05 Thread Douglas Bates
On Wed, Mar 5, 2008 at 7:43 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 3/5/2008 8:21 AM, gerardus vanneste wrote: Hello I've stumbled upon a problem for inversion of a matrix with large values, and I haven't found a solution yet... Someone with experience in numerical linear

[R] Matrix addition

2008-02-19 Thread Marlin Keith Cox
Matt, I know you are probably busy with work, but I cannot help buy asking you these R questions. If it is bothersome, please let me know and I will stick with the R help... but I have two matrices X [,1] [,2] [,3] [,4] [,5] [,6] [1,] 660 693.00 726.0 759.00 792.0 825.00 [2,]

[R] Matrix inversion

2008-02-18 Thread Ben Domingue
Howdy, I am trying to invert a matrix for the purposes of least squares. I have tried a number of things, and the variety of results has me confused. 1. When I try solve() I get the following: Error in solve.default(t(X) %*% X) : system is computationally singular: reciprocal condition number =

Re: [R] Matrix inversion

2008-02-18 Thread Bill.Venables
Ben Domingue asks: I am trying to invert a matrix for the purposes of least squares. I have tried a number of things, and the variety of results has me confused. Don't be. 1. When I try solve() I get the following: Error in solve.default(t(X) %*% X) : system is computationally singular:

Re: [R] matrix loop

2008-02-09 Thread David Winsemius
John Kane [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: You are trying to create a matrix in the loop Try creating the matrix before the loop m - 1:5 n-1:10 y - matrix(rep(NA, 50), nrow=m) # I think that this might actually work: y - matrix(rep(NA, 50), nrow=max(m)) for(i in

Re: [R] matrix loop

2008-02-08 Thread John Kane
You are trying to create a matrix in the loop Try creating the matrix before the loop m - 1:5 n-1:10 y - matrix(rep(NA, 50), nrow=m) for(i in 1:length(m)) { for(j in 1:length(n)) { y[i,j]=sum(i,j) } } However as Jim Holtman points out you can do this particular matrix by

Re: [R] matrix loop

2008-02-06 Thread jim holtman
What exactly are you intending the loop to do? Why do you have the 'as.matrix' in the middle of the loop? Where was 'y' defined? Does this do what you want? outer(1:5, 1:10, +) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]23456789 1011

Re: [R] matrix creation -- answer: data.matrix()

2008-01-29 Thread Martin Maechler
GS == Gavin Simpson [EMAIL PROTECTED] on Tue, 29 Jan 2008 00:09:05 + writes: GS hits=-2.6 tests=BAYES_00 GS X-USF-Spam-Flag: NO GS On Mon, 2008-01-28 at 12:17 -0700, Michelle DePrenger-Levin wrote: I was asked for the following information and hope it might help those

Re: [R] matrix creation

2008-01-28 Thread Gavin Simpson
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO Hi Michelle, You don't show your read.csv or read.table call, nor the output of str(obj) where obj is the name of the object you read the data into. I notice that you have explicit 0 and NA. Is there a chance that you have entered NA into the cells

[R] matrix creation

2008-01-28 Thread Michelle DePrenger-Levin
Hello, I am trying to create multiple matrices (to run a PVA) but can't import all of them from a .csv without the numbers treated as labels and not factors. I can enter the matrix slowly: Site05_96 - matrix(c(0.07,0,0.03,0.00,NA,0.00, 0.09,0.16667,0.31,0.42,NA,0.00,

Re: [R] matrix creation

2008-01-28 Thread Michelle DePrenger-Levin
I was asked for the following information and hope it might help those who could answer my question... To import the table I used: AsMi05test=read.csv(C:/AsMi_Site05_1998.csv) str(AsMi05test) `data.frame': 12 obs. of 8 variables: $ X : Factor w/ 6 levels

Re: [R] matrix creation

2008-01-28 Thread Gavin Simpson
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO On Mon, 2008-01-28 at 12:17 -0700, Michelle DePrenger-Levin wrote: I was asked for the following information and hope it might help those who could answer my question... That looks fine to me Michelle. You will have problems with as.matrix on this

Re: [R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Marc Schwartz
Brant Inman wrote: R-helpers: I am experiencing some odd behavior with the 'matrix' function that I have not experienced before and was wondering if there is something that I was missing in my code. - sessionInfo() R version 2.6.1 (2007-11-26)

Re: [R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Thomas Lumley
On Sun, 20 Jan 2008, Brant Inman wrote: Note the problems in rows 15, 21, 37 and 43. They should read [0.5, 45.5], [14.5, 21.5], etc... The matrix function seems to be rounding the second column up to the next integer. Why would this occur? Can I do something to prevent this? I would

[R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Brant Inman
R-helpers: I am experiencing some odd behavior with the 'matrix' function that I have not experienced before and was wondering if there is something that I was missing in my code. - sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale:

Re: [R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Henrik Bengtsson
Check your getOption(digits). Default is typically 7. Either you or a package/function sets it to a small value. You get that **output** with options(digits=n) where n=1,2,3. /Henrik On Jan 20, 2008 7:13 PM, Thomas Lumley [EMAIL PROTECTED] wrote: On Sun, 20 Jan 2008, Brant Inman wrote:

Re: [R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Brant Inman
*As usual, the R-helpers were bang on. Some package must have modified my digits option without me noticing.* ** *--* ** * test - matrix(c(7,47,4,38,20,96,1,14,10,48,2,101,12,161, + 1,28,1,19,22,49,25,162,31,200,9,39,22,193, + 0.5,45.5,31,131,4,75,31,220,7,55,3,91,14.5, +

Re: [R] 'matrix' returns integer instead of decimal

2008-01-20 Thread Ben Bolker
Brant Inman brant.inman at gmail.com writes: *As usual, the R-helpers were bang on. Some package must have modified my digits option without me noticing.* I'm pretty certain that the arm package is the problem. options(digits) $digits [1] 7 library(arm) Loading required package: MASS

Re: [R] matrix to gal object

2007-12-22 Thread Roger Bivand
bernardo lagos alvarez blacertain at gmail.com writes: useR's I need transform the matrix wdat [,1] [,2] [,3] [,4] [,5] [,6] [1,]010110 [2,]100110 [3,]000011 [4,]110010 [5,]1

[R] matrix to gal object

2007-12-21 Thread bernardo lagos alvarez
useR's I need transform the matrix wdat [,1] [,2] [,3] [,4] [,5] [,6] [1,]010110 [2,]100110 [3,]000011 [4,]110010 [5,]111100 [6,]001000 to gal

[R] Matrix Inversion

2007-12-12 Thread Wang Chengbin
I got the following error: a = read.csv(mat.csv) b = as.matrix(a) tb = t(b) bb = tb %*% b dim(bb) ibb = solve(bb) bb %*% ibb ibb = solve(bb) Error in solve.default(bb) : system is computationally singular: reciprocal condition number = 1.77573e-19 Are there any ways to find more information

Re: [R] Matrix Inversion

2007-12-12 Thread Robin Hankin
Hello Wang matrix bb is symmetric positive semidefinite, so algebraically the eigenvalues are nonnegative. I would use bb - crossprod(b) to calculate bb (faster and possibly more accurate) Look at eigen(bb,TRUE,TRUE)$values (see ?eigen for the meaning of the arguments) to see how many very

Re: [R] Matrix Inversion

2007-12-12 Thread Peter Dalgaard
Wang Chengbin wrote: I got the following error: a = read.csv(mat.csv) b = as.matrix(a) tb = t(b) bb = tb %*% b dim(bb) ibb = solve(bb) bb %*% ibb ibb = solve(bb) Error in solve.default(bb) : system is computationally singular: reciprocal condition number = 1.77573e-19

Re: [R] matrix graph

2007-12-12 Thread Julian Burgos
The basic functions you need are image() contour() although I like better the plot.surface() function in the 'fields' package. Julian threshold wrote: Hi All, simple question: do you know how to graph the following object/matrix in a 'surface manner': [,1] [,2] [,3]

[R] matrix graph

2007-12-11 Thread threshold
Hi All, simple question: do you know how to graph the following object/matrix in a 'surface manner': [,1] [,2] [,3][,4] [,5][,6] [1,] -0.154 -0.065 0.129 0.637 0.780 0.221 [2,] 0.236 0.580 0.448 0.729 0.859 0.475 [3,] 0.401 0.506 0.310 0.650 0.822 0.448 [4,]

Re: [R] matrix graph

2007-12-11 Thread Dylan Beaudette
On Tuesday 11 December 2007, threshold wrote: Hi All, simple question: do you know how to graph the following object/matrix in a 'surface manner': [,1] [,2] [,3][,4] [,5][,6] [1,] -0.154 -0.065 0.129 0.637 0.780 0.221 [2,] 0.236 0.580 0.448 0.729 0.859 0.475

Re: [R] matrix graph

2007-12-11 Thread Tony Plate
Try these: x - matrix(rnorm(100), ncol=10) persp(x) contour(x) Also, look at the R graph gallery: http://addictedtor.free.fr/graphiques/ -- Tony Plate threshold wrote: Hi All, simple question: do you know how to graph the following object/matrix in a 'surface manner':

Re: [R] matrix (column-wise) multiple regression

2007-11-23 Thread Gabor Grothendieck
Perhaps something like this: idx - 1:2 lm(as.matrix(iris[idx]) ~., iris[-idx]) Call: lm(formula = as.matrix(iris[idx]) ~ ., data = iris[-idx]) Coefficients: Sepal.Length Sepal.Width (Intercept) 3.682982 3.048497 Petal.Length0.905946 0.154676

Re: [R] matrix (column-wise) multiple regression

2007-11-23 Thread Gabor Grothendieck
You can look at the components of the output using str and pick out what you want using $ and attr. idx - 1:2 z - lm(as.matrix(iris[idx]) ~., iris[-idx]) str(z) str(summary(z)) On Nov 23, 2007 1:10 PM, Morgan Hough [EMAIL PROTECTED] wrote: Hi Gabor, Thanks for your reply. I have it working

[R] matrix (column-wise) multiple regression

2007-11-23 Thread Morgan Hough
Hi there, I am analyzing a table of brain volume measures where each brain area (183 of them) is a column with a label and volume values. I have another table of explanatory variables (age, gender, diagnosis and IntraCranialVol) that I have been using to model the brain volume differences. I

Re: [R] matrix (column-wise) multiple regression

2007-11-23 Thread Morgan Hough
Hi Gabor, Thanks for your reply. I have it working now. A couple of follow-ups if I may. I have a shell script parsing the output to find the brain areas where there is a significant effect of diagnosis but its a bit of a hack. I was wondering whether there are R specific tools for

[R] Matrix of dummies from a vector

2007-11-22 Thread Serguei Kaniovski
Hallo From a variable x that defines, say, four classes, I would like to define the matrix mat of dummy variables indicating the classes, i.e. x - c(1,1,1,1,2,2,2,3,3,3,4,4) mat - matrix(c(1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,0,1,

[R] matrix elementwise average with NA's

2007-11-21 Thread Gregory Gentlemen
Hello fellow R users, I have a matrix computation that I imagine should be relatively easy to do, however I cannot figure out a nice way to do it. I have two matrices, for example mat1 - matrix(c(1:5,rep(NA,5), 6:10), nrow=3, byrow=T) mat2 - matrix(c(2:6, 6:10, rep(NA,5)), nrow=3, byrow=T)

Re: [R] matrix elementwise average with NA's

2007-11-21 Thread Matthew Keller
Maybe there is a more elegant solution, but here is one possibility: mat1[is.na(mat1)]-mat2[is.na(mat1)] mat2[is.na(mat2)]-mat1[is.na(mat2)] (mat1+mat2)/2 On Nov 21, 2007 12:30 PM, Gregory Gentlemen [EMAIL PROTECTED] wrote: Hello fellow R users, I have a matrix computation that I imagine

Re: [R] matrix elementwise average with NA's

2007-11-21 Thread Marc Schwartz
On Wed, 2007-11-21 at 14:30 -0500, Gregory Gentlemen wrote: Hello fellow R users, I have a matrix computation that I imagine should be relatively easy to do, however I cannot figure out a nice way to do it. I have two matrices, for example mat1 - matrix(c(1:5,rep(NA,5), 6:10), nrow=3,

[R] Matrix package problem: dsyMatrix %*% vector gives error

2007-11-01 Thread Gerrit Eichner
Dear UseRs, here is an example scenario presenting my problem: Multiplying a dsyMatrix with a numeric vector results in an error (unfortunately in German due to my locale): (M1 - Matrix( c( 1, 2, 2, 2, 1, 2, 2, 2, 1), nrow = 3)) 3 x 3 Matrix of class dsyMatrix [,1] [,2] [,3] [1,]1

Re: [R] Matrix package problem: dsyMatrix %*% vector gives error

2007-11-01 Thread Prof Brian Ripley
As the posting guide says: If you are using an old version of R and think it does not work properly. upgrade to the latest version and try that, before posting. This works in current R and current Matrix (0.999375-3) It also says If the question relates to a contributed package , e.g.,

Re: [R] Matrix manipulation

2007-10-22 Thread Tim Calkins
use the '-' feature. mat - matrix(rnorm(100), nrow = 10) #snip the second row mat[-2,] #snip the third column mat[,-3] #snip rows 5 and 7 mat[-c(5,7),] cheers tc On 10/23/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi everyone, suppose I have a 2D matrix, is there a command to snip out

[R] Matrix package installation problem

2007-10-05 Thread Jean Marie Beduin
I need some help I try to install the following package: Matrix_0.999375-2.tar.gz I have the needed package and R version. My operating sytem is linux suse 10.1. I have the following error message /usr/lib/gcc/i586-suse-linux/4.1.0/../../../../i586-suse-linux/bin/ld: ne peut trouver -lgfortran

Re: [R] Matrix package installation problem

2007-10-05 Thread Martin Maechler
JMB == Jean Marie Beduin [EMAIL PROTECTED] on Fri, 05 Oct 2007 09:10:11 +0200 writes: JMB I need some help yes JMB I try to install the following package: Matrix_0.999375-2.tar.gz JMB I have the needed package and R version. JMB My operating sytem is linux suse 10.1.

Re: [R] Matrix bar plot

2007-10-04 Thread Todd A. Gibson
On Thu, Oct 04, 2007 at 06:15:34PM -0500, hadley wickham wrote: Why would you want a plot that looks like that? Half the bars are hidden behind other bars! I would rotate it such that all bars are visible. -TAG __ R-help@r-project.org mailing list

Re: [R] Matrix bar plot

2007-10-04 Thread Deepayan Sarkar
On 10/4/07, Todd A. Gibson [EMAIL PROTECTED] wrote: On Thu, Oct 04, 2007 at 06:15:34PM -0500, hadley wickham wrote: Why would you want a plot that looks like that? Half the bars are hidden behind other bars! I would rotate it such that all bars are visible. If you are really, really, sure

Re: [R] Matrix bar plot

2007-10-04 Thread Bert Gunter
On Thu, Oct 04, 2007 at 06:15:34PM -0500, hadley wickham wrote: Why would you want a plot that looks like that? Half the bars are hidden behind other bars! I would rotate it such that all bars are visible. -TAG -- thus distorting the perspective even more so that you can not make accurate

Re: [R] Matrix bar plot

2007-10-04 Thread jim holtman
check out the 'rgl' package On 10/4/07, Todd A. Gibson [EMAIL PROTECTED] wrote: Hello, Does R have any facility to create a plot that looks similar to this: http://www.augustcouncil.com/~tgibson/barmatrix.jpg Thank you, -TAG Todd A. Gibson __

<    4   5   6   7   8   9   10   >