similar to: logical or for two vectors or matrices

Displaying 20 results from an estimated 20000 matches similar to: "logical or for two vectors or matrices"

2007 Jan 30
5
how to join two arrays using their column names intersection
Dear all, I have a problem that may be someone of you can help. I am a newbie and do not find how to do it in manuals. I have two arrays, for example: ar1 <- array(data=c(1:16),dim=c(4,4)) ar2 <- array(data=c(1:16),dim=c(4,4)) colnames(ar1)<-c("A","B","D","E") colnames(ar2)<-c("C","A","E","B") > ar1
2008 Jun 02
4
exit function in R?
Hi, This is likely an stupid question, but I cannot find the solution. I am searching for an "exit" function, to end the execution of an R script if some condition is not filled. Any clue? Thank you in advance! Federico
2009 Oct 29
3
x-y plot as an histogram
Hi, I am investigating a problem for which I found no solution. I have a matrix with two columns. I have plotted it as an x-y plot (plot(matrix[,1],matrix[,2]) But this is not apropriate for my purposes. I need to group the data in matrix[,1] into groups (as an histogram would do). Then I have to calculate the average of matrix[,2] for each group. Before starting with loops and loops I
2007 May 04
2
Get the difference between two matrices with different length
Hello, I have got two matrices with different length. The matrices have 3 columuns. The first two are coordinates. The third is a measurement. Now I want to get a subtraction between every single value of the third column (between matrix1 and matrix2), but only if the two first coordinates in matrix1 and matrix2 are the same. I tried "FUN=?" in aggregate and ave, but I don't know
2007 Feb 14
2
font size in plots
Dear members of the list, it is likely a stupid question but I cannot find the information neither in R manuals nor in google. I am generating a plot (from hclust results) but I cannot see properly the labels because the default font size is too large. How can I change it? Thanks! Federico
2008 Mar 13
2
joining matrices, vectors, scalars in one object
Hi, I have: a <- matrix(c(0,1,0,1),nrow=2) b <- matrix(c(1,1,1,0,0,0),nrow=3) c <- 1 d <- c(1,0,1) And I would like to join them in an object 'thing' so that I can access a, b, c, or d through an index in a for loop. For example: thing[4] would return [1] 1 0 1 Note however, that I have many of these 'thing' components. So many that a command like thing
2005 Feb 21
5
Compare rows of two matrices
Hello, #I have two matrices, eg.: y <- matrix( c(20, NA, NA, 45, 50, 19, 32, 101, 10, 22, NA, NA, 80, 49, 61, 190), ncol=4 ) x <- matrix( c(20, NA, NA, NA, 50, 19, 32, 101, 10, 22, NA, NA, 80, 49, 61, 190), ncol=4 ) #Whereas x contains all NA?s from y plus some additional NA?s. #I want to find the index of these additional NA?s. I think, there must be a very
2006 Jun 07
3
smoothing plot(x, type ='l')
Hi All, I am using plot(x, type = 'l') for some plotting, but I would like rounded edges rather than jagged edges in the plot (purely for aestetic reasons). How could I achieve that? Cheers, Federico -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020
2007 Apr 26
1
comparing two matrices, row by row
Estimated people, I have two matrices: ar1 <- array(data=c(1:16),dim=c(4,4)) ar2 <- array(data=c(1,2,3,3,5:16),dim=c(4,4)) They only differ in the fourth row. I would like to compare them in order to know which columns are equal. The following works, but I would like to have a better solution, and not to use what someone called "prehistorical loops": for(i in
2006 Jul 06
3
Comparing two matrices
hi: I have matrix with dimensions(200 X 20,000). I have another file, a tab-delim file where first column variables are row names and second column variables are column names. For instance: > tmat Apple Orange Mango Grape Star A 0 0 0 0 0 O 0 0 0 0 0 M 0 0 0 0 0 G 0 0 0 0 0 S 0 0 0 0 0
2006 Sep 26
5
putting stuff into bins...
Hi All, I have a vector of data, a vector of bin breakpoints and I want to put my data in the bins and then extract fanciful informations like the mean value of each bin. I know I can write my own function, but I would have thought that R should have somewhere a function that took as arguments something like (data, breaks, what to do with the data in the bins). I surey could not find it
2007 Jul 18
2
EM unsupervised clustering
Hi All, I have a n x m matrix. The n rows are individuals, the m columns are variables. The matrix is in itself a collection of 1s (if a variable is observed for an individual), and 0s (is there is no observation). Something like: [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 0 1 1 0 0 [2,] 1 0 1 1 0 0 [3,] 1 0 1 1 0 0 [4,] 0 1 0
2006 Jun 27
1
Adding elements of matrices of different dimensions
If I have two matrices: > a<-matrix(1:5,ncol=1) [,1] [1,] 1 [2,] 2 [3,] 3 [4,] 4 [5,] 5 > b<-matrix(1:50,ncol=10) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 6 11 16 21 26 31 36 41 46 [2,] 2 7 12 17 22 27 32 37 42 47 [3,] 3 8 13 18 23 28 33 38 43 48 [4,] 4 9 14 19
2005 Mar 16
8
Summing up matrices in a list
Dear all, I think that my question is very simple but I failed to solve it. I have a list which elements are matrices like this: >mylist [[1]] [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 [[2]] [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12 I'd like to create a matrix M<-mylist[[1]]+mylist[[2]] [,1] [,2] [,3] [1,] 8 12 16 [2,] 10 14 18
2008 Jan 31
3
fastest way to compute the squared Euclidean distance between two vectors in R
I have a program which needs to compute squared Euclidean distance between two vectors million of times, which the Rprof shows is the bottleneck. I wondered if there is any faster way than my own simple function distance2 = function(x1, x2) { temp = x1-x2 sum(temp*temp) } I have searched the R-help archives and can not find anything except when the arguments are matrices. Thanks for any
2008 Jun 04
4
sum of unknown number of matrices
Hi R, I have a list of matrices. I need to get the sum of all the matrices in the list. Example: a=b=c=d=matrix(1:4,2,2) l=list(a,b,c,d) I need: > a+b+c+d [,1] [,2] [1,] 4 12 [2,] 8 16 Something like do.call("+",l) is not working...why is this? I may not be knowing the number of matrices in the list... Thanks, Shubha This e-mail
2005 Nov 21
3
Comparing rows of matrices with different dimensions
Hi there, I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly? Here it is: I have two matrices: a [,1] [,2] [,3] [1,] 1 4 9 [2,] 2 6 10 [3,] 3 6 11 [4,] 4 8 12 b [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 Now I want to find
2004 May 12
2
Extracting data from matrices
Dear R list I have an m * n matrix P and a vector V of length n containing indices for rows in P. For each of the m columns I want to extract the value in the row specified by V, and put these values into a new vector W of length n. At present I am doing this with a for.... loop, but I imagine there is a faster way that doesn?t involve loops. If anyone knows the way I would be most grateful.
2005 Jan 14
3
summing subsets of rows matrices
I have a large data matrix (4460X3500) and I want to sum row subsets in groups of 10 (bin). Is there an efficient way to do this in R without using loops. Looping takes forever to perform this task! For example suppose we have the matrix > matrix(1:12,6,2) [,1] [,2] [1,] 1 7 [2,] 2 8 [3,] 3 9 [4,] 4 10 [5,] 5 11 [6,] 6 12 my problem is to sdum for
2006 Feb 28
4
subsetting a list of matrices
Hi All, I have a list of matrices: > x [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 > y [,1] [,2] [,3] [,4] [,5] [,6] [1,] 18 21 24 27 30 33 [2,] 19 22 25 28 31 34 [3,] 20 23 26 29 32 35 > z =list(x,y) I want to create a second list that is has a subset each matrix in the list subsetting so I get the 2nd and 3rd row of each (and