similar to: How to combine two matrix or vectors

Displaying 20 results from an estimated 30000 matches similar to: "How to combine two matrix or vectors"

2010 Nov 08
4
Create Matrix of 2 Dim from two vectors
Hello, I have two data. x<-c(1, 2, 3) y<-c(4,5,6) How do i create matrix of 3 by 3 from this two, such that (1,4) (1,5) (1,6) (2,4) (2,5) (2,6) (3,4) (3,5) (3,6) I tried some thing like this: xy <- as.data.frame(c(0,0,0), dim=c(3,3)) for(i in 1:3) for(j in 1:3) xy[i][j]<-c(x[i],y[j]) but i got errors..!!!! any help would appreciate -- View this message in
2013 Mar 14
2
merge function to combine two tables
Dear R-help members I would be grateful if anyone could help me with the following problem: I would like to combine two matrices (Schmitt_15 and Schmitt_16, they are attached) which have a species presence/absence x sampling plot structure. The aim would be to have in the end only one matrix which shows all existing species and their presence/absence on all the different plots. To do this I
2011 Jan 29
1
How to apply a two-place function to each combination of elements in two vectors of different lengths?
Dear expeRts, I somehow can't manage to do the following: Given two vectors x and y of lengths 3 and 2, respectively, I would like to apply a function to each combination of the entries of x and y and receive a 3-by-2 matrix containing the results. Now outer() seems to be the way to go, but outer() expands the vectors first, which leads to errors in my function. Here is the minimal example:
2010 Apr 22
2
Compare two data frames
I wonder if there is a more efficient way to do this task. Suppose I have two data frames, such as d1 <- data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9)) d2 <- d1[, c('y', 'x')] The first dataframe d1 has more variables than d2 and the variable columns are in a different order. So, what I want to do is compare the two frames on the variables that are common between
2011 Jul 06
3
finding the intersection of two vectors
Hi, Suppose I have two vectors, not necessarily the same length (in fact, they usually are different lengths): y.1 that has increasing values between 0 and 1; y.2 that has decreasing values between 1.0 and 0. You can picture these as being supply (= y.1) and demand (= y.2) curves from economics. I typically plot these vectors on the same graph against a common x variable, which happens to
2010 Apr 23
1
Combinations with restrictions
Hi! Is there any easy/fast way to combine vectors with restrictions? Example: a=c(1,2,3), b=c(4,5,6), c=c(7,8,9) I want all combinations of this 3 vectors with length=2. Like this: 1,4 1,5 1,6 1,7 1,8 1,9 2,4 2,5 2,6 2,7 ... and so on. Thanks in advance. [[alternative HTML version deleted]]
2011 Aug 27
3
all combinations of the elements of two vectors
Dear R-help readers, I'm sure this problem has been answered but I can't find the solution. I have two vectors v1 <- c("a","b") v2 <- c(1,2,3) I want an easy way to produce every possible combination of v1, v2 elements Ie I want to produce c("a1","a2","a3", "b1","b2","b3") regards Desmond Desmond
2008 Feb 25
2
union of two data frames
I have a thirty thousand row data frame imported from excel and a 60,000 row data frame imported from excel. they share a common subset of the same data and I would like to combine the two into one data frame merged together on the data in common. I have looked at the help file for merge and intersect and cbind and rbind etc... And I can't figure it out. Thanks in advance Stephen --
2012 Feb 02
3
How to get intersection of multiple vectors?
v1<-c("a","b","c","d") v2<-c("a","b","e") v3<-c("a","f","g") I want to get the intersection of v1,v2,v3,ie "a" How can I do then? What I know is only for 2 vectors via "intersect" function,but don't know how to deal with multiple vectors. Many thanks
2005 Mar 28
2
Generating list of vector coordinates
Hi. Can anyone suggest a simple way to obtain in R a list of vector coordinates of the following form? The code below is Mathematica. In[5]:= Flatten[Table[{i,j,k},{i,3},{j,4},{k,5}], 2] Out[5]= {{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,1,5},{1,2,1},{1,2,2},{1,2,3},{1 ,2,4},{1,2, 5},{1,3,1},{1,3,2},{1,3,3},{1,3,4},{1,3,5},{1,4,1},{1,4,2},{1,4,3}, {1,4,
2010 Sep 16
2
How to combine matrix and vector
Dear fellows, I am a novice in R. I would like to combine a matrix and a vector. Assume that we have the matrix a and the vector b with same length of column. a<-matrix(seq(1:10),nrow=2,ncol=5,byrow=TRUE) a= 1 2 3 4 5 6 7 8 9 10 b<-t(c(11,12,13,14,15)) b= 11 12 13 14 15 Then, I want to combine a and b as follows. c= 1 2 3 4 5 6 7 8 9
2009 Sep 21
2
Combine vectors in order to form matrixes with combn
Hello! I've a problem with the combn function and a set of vector. I would like to make a simple combination where, instead of scalars, i would like to combine vector, in order to form matrixes. In other words, i have nineteen 6-items vectors (for example coef1-coef19), that i would like to combine in n!/k!(n-k)! 6x6 matrixes. I tried with a code like this mma <-
2008 Mar 13
3
fast way to compare two matrices of combinations
I have a list (length 750), each element containing a vector of unique strings (unique gene ids), with length up to ~40 (median 15). I want to compile a matrix of all possible triplets and their frequency within gene elements. Using combn and a lot of looping, I am accomplishing this but it is VERY slow. I've tried to figure out a way to vectorize this, using "match" and
2004 May 05
4
anyone know how to combine two vector with some # overlaped?
Hi, there, Suppose I have two vector say x=c(1 2 3 4 5) and y=(2 3 6 7). Then I want to combine these two vector together and get z=c(1 2 3 4 5 6 7) with 2 and 3 only appear once. I want to extend this one to a general case(say more than 100 elements in x and y and each time I don't know which elements are the same). Do you happen to know how to do this and which command should use? Thank
2010 May 06
3
Intersection list
How can I create intersections of vectors? a <- c(1,2,3) b <- c(1,5,6) the intersected list c should contain c(1)... Ralf
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and
2007 Nov 21
1
How to select rows with identical index from two matrix?
Dear list, I have two martix like these, each rows with name in the matrix. I try to select rows with identical name from two matrix and calculate their correlation. Matrix1: 2-Sep 9 5.5 1 7.18 10.0 8 139.45 2-Sep 7 4.9 15 8.22 61.68 9 123.62 4-Sep 5-Sep AAMP A2M A2M . . . Matrix2: 2-Sep 4 7 1 6.8 12 8 19.4
2005 May 05
2
Intersection of more than two groups in one function?
Hi all, As far as I can tell, the only canned way to do an intersect between two vectors of ints is the intersect(vec1, vec2) function -- is there another function I'm missing for intersecting more than two vectors?? TIA, Ken
2011 Apr 18
1
Extract indices after comparing two vectors
Dear All, I would like to ask a question about how to locate the indices after comparing two numeric vectors. Say, I have, A <- c(1,2,3,4) and A <- c(0,3,1,5) and we cmpare: > idx <- A<B So: > idx [1] FALSE TRUE FALSE TRUE Question 1: I would like to get a vector that stores the indices for entries of A such that this relationship is true. In this case, a vector idx1
2009 Sep 15
2
Subsetting matrix with values from vector
Hello, I have a large matrix (data), in which there is a column offerid. The values are numbers (lets say 1:5) There is another vector (idnew), which contains some of the offerids and many more (3:10). I want a subset of the matrix wiith only those rows, which match the criteria of the vector. How can I make it work? Thanks! -- View this message in context: