Re: [R] matrices call a function element-wise

2011-01-03 Thread Dennis Murphy
Hi: The idea is as follows: * string your four matrices into vectors, cbinding them so that the columns correspond to what you want as the (1,1), (1, 2), (2, 1) and (2, 2) elements, respectively, of the matrix/table to be used for the Fisher test; * Operate row-wise on the constructed matr

Re: [R] matrices call a function element-wise

2011-01-03 Thread Jonathan Christensen
Hi, I would recommend reformatting the data as a 2x2x1000 array and using apply. Jonathan On Mon, Jan 3, 2011 at 7:57 AM, zhaoxing731 wrote: > Hello > > I have 4 1000*1000 matrix A,B,C,D. I want to use the corresponding element of > the 4 matrices. Using the "for loop" as follow: > > E<-o > f

Re: [R] matrices call a function element-wise

2011-01-03 Thread Jonathan P Daily
org wrote on 01/03/2011 09:57:14 AM: > [image removed] > > [R] matrices call a function element-wise > > zhaoxing731 > > to: > > R-help > > 01/03/2011 01:46 PM > > Sent by: > > r-help-boun...@r-project.org > > Hello > > I have 4 100

[R] matrices call a function element-wise

2011-01-03 Thread zhaoxing731
Hello I have 4 1000*1000 matrix A,B,C,D. I want to use the corresponding element of the 4 matrices. Using the "for loop" as follow: E<-o for (i in 1:1000) {for (j in 1:1000) { E<-fisher.test(matrix(c(A[i][j],B[i][j],C[i][j],D[i][j]),2))#call fisher.test for every element } }

Re: [R] Matrices with randomly generated entries

2010-01-20 Thread GlenB
Why not just use matrix(runif(9),nrow=3) ? -- View this message in context: http://n4.nabble.com/Matrices-with-randomly-generated-entries-tp1018777p1024617.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org ma

Re: [R] Matrices with randomly generated entries

2010-01-20 Thread David Winsemius
On Jan 20, 2010, at 4:55 PM, jshort wrote: I'm attempting to generate matrices where the entries are randomly generated numbers of specified distribution. The following code was an attempt to create a 3 by 3 matrix, where my entries where randomly generated from a uniform (0,1) distributio

[R] Matrices with randomly generated entries

2010-01-20 Thread jshort
I'm attempting to generate matrices where the entries are randomly generated numbers of specified distribution. The following code was an attempt to create a 3 by 3 matrix, where my entries where randomly generated from a uniform (0,1) distribution. x = matrix(0,ncol = 3, byrow = T) for(i in 1:

Re: [R] Matrices

2009-08-10 Thread Gavin Simpson
On Mon, 2009-08-10 at 14:02 -0400, mmv.listservs wrote: > Your example works because you have only 5 really long labels. I tried > changing 5 to 474 because that is how many I have and the plot looks > illegible. Should I increase the margin or the height of the plotting > window? Thanks for your h

Re: [R] Matrices

2009-08-10 Thread mmv.listservs
Your example works because you have only 5 really long labels. I tried changing 5 to 474 because that is how many I have and the plot looks illegible. Should I increase the margin or the height of the plotting window? Thanks for your help again. ## dummy data set.seed(123) dummy <- data.frame(A =

Re: [R] Matrices

2009-08-10 Thread Gavin Simpson
On Mon, 2009-08-10 at 13:41 -0400, mmv.listservs wrote: > I should give an example Thanks for that - I just two seconds ago sent a reply to the list complaining because you didn't provide one. However, the code below doesn't work. > > for(p in 1:100) > { > str <- paste("Task", p, sep=" ") >

Re: [R] Matrices

2009-08-10 Thread Gavin Simpson
On Mon, 2009-08-10 at 13:33 -0400, mmv.listservs wrote: > Gavin and Stefan, > > Both the subset commands and the flag were exactly what I needed. On another > note, I'm dealing with variables that are categorical and have long names > like "Task XYZ", "Task ABC" "Task CCC" > > When I try to plot

Re: [R] Matrices

2009-08-10 Thread mmv.listservs
I should give an example for(p in 1:100) { str <- paste("Task", p, sep=" ") task_name[p] <- str } ## first set the random seed so we get the same results set.seed(123) ## now produce some dummy data dummy <- data.frame(A = sample(LETTERS[1:4], 100, replace = TRUE), B =

Re: [R] Matrices

2009-08-10 Thread mmv.listservs
Gavin and Stefan, Both the subset commands and the flag were exactly what I needed. On another note, I'm dealing with variables that are categorical and have long names like "Task XYZ", "Task ABC" "Task CCC" When I try to plot against the probability it doesn't show me the Task name anymore. How

Re: [R] Matrices

2009-08-10 Thread Gavin Simpson
On Mon, 2009-08-10 at 11:17 -0400, mmv.listservs wrote: > yy<-poisson2[poisson2$Reboot.Id=="Reboot > 2",poisson2$Task.Status=="F",,drop=FALSE] The above doesn't make any sense and can't be working or doing what you think it is doing. Lets dissect this command: yy <- poisson2[poisson2$Reboot.Id==

Re: [R] Matrices

2009-08-10 Thread mmv.listservs
yy<-poisson2[poisson2$Reboot.Id=="Reboot 2",poisson2$Task.Status=="F",,drop=FALSE] doesn't work either? Any other ideas? On Mon, Aug 10, 2009 at 11:01 AM, mmv.listservs wrote: > How do you access all the column attributes associated with a column reboot > instance? > > The variables > > poisson

[R] Matrices

2009-08-10 Thread mmv.listservs
How do you access all the column attributes associated with a column reboot instance? The variables poisson2 ~ a matrix with 10,000 rows and 8 column attributes. Things I tried: This command only returns a vector for one of the column attributes x1_prob <- poisson2$Probability[poisson2$Reboot.

Re: [R] Matrices in R - Simple question?

2009-03-10 Thread David Winsemius
I suspect you probably need to provide an example that illustrates why this seems difficult: > x <- 1:10 > f1 <- function(x) exp(x) > g1 <- function (x) log(x) > h1 <- function (x) x^(1/2) # any of these functions would return a 10 element vector if given x as an argument > f1(x)*g1(x)*h1(x

[R] Matrices in R - Simple question?

2009-03-10 Thread Lars Bishop
Hi, I'm a new R user and would appreciate your help regarding the following: Can I create a matrix whose elements are n functions of a vector x? In my problem I have 3 vectors (a,b,c) with elements a=[f1(x) f2(x)fn(x)]; b=[g1(x) g2(x)gn(x)]; c=[h1(x) h2(x)hn(x)]. I need to create a fin