similar to: looking for a faster way to compare two columns of a matrix

Displaying 20 results from an estimated 30000 matches similar to: "looking for a faster way to compare two columns of a matrix"

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
2010 Nov 17
1
efficient conversion of matrix column rows to list elements
Hi List, I'm hoping to get opinions for enhancing the efficiency of the following code designed to take a vector of probabilities (outcomes) and calculate a union of the probability space. As part of the union calculation, combn() must be used, which returns a matrix, and the parallelized version of lapply() provided in the multicore package requires a list. I've found that
2009 May 11
3
Looking for a quick way to combine rows in a matrix
I'm working with genotype data in a frequency table: > a=matrix(1:16, nrow=4) > rownames(a)=c("AA","AT","TA","TT") > a [,1] [,2] [,3] [,4] AA 1 5 9 13 AT 2 6 10 14 TA 3 7 11 15 TT 4 8 12 16 'AT' and 'TA' are essentially the same, and I'd like to combine (add) the rows to reflect
2009 Nov 16
1
No Visible Binding for global variable
While building a package, I see the following: * checking R code for possible problems ... NOTE cheat.fit: no visible binding for global variable 'Zobs' plot.jml: no visible binding for global variable 'Var1' I see the issue has come up before, but I'm having a hard time discerning how solutions applied elsewhere would apply here. The entire code for both functions is below,
2008 Aug 15
2
Combination with repetition
Hi there! I can't find any information about creating combinations with repetitions in R. The function combn() does create combinations, but _without_ repetitions. Here is what I need to do: svIter <- 1000 xx <- matrix(rnorm(m*n), c(m, n)) sequence <- seq(range(xx)[1], range(xx)[2], length.out = svIter^(1/q)) expand.grid(secuence, secuence, .../q times/..., secuence) That is,
2011 Sep 26
3
Nearest neighbour in a matrix
Hello all, I am brand new to R and doing an exercise for a class. I need to find the nearest neighbour for points in the following matrix: > DistanceMatrix x1 x2 x3 x4 x5 [1,] 0.000000 2.828427 1.581139 2.236068 2.000000 [2,] 2.828427 0.000000 1.581139 4.123106 2.000000 [3,] 1.581139 1.581139 0.000000 2.549510 2.121320 [4,] 2.236068 4.123106 2.549510
2007 Jul 27
4
Looping through all possible combinations of cases
Hello! I have a regular data frame (DATA) with 10 people and 1 column ('variable'). Its cases are people with names ('a', 'b', 'c', 'd', 'e', 'f', etc.). I would like to write a function that would sum up the values on 'variable' of all possible combinations of people, i.e. 1. I would like to write a loop - in such a way that it
2012 Aug 02
1
sapply and matrix command
HI, You can also try this: d<-1:25 A<-sample(combn(20:30,2)) B<-sample(combn(20:30,2)) lapply(d,function(x) matrix(c(1,A[x],B[x],1),2,2)) [[1]] [,1] [,2] [1,] 1 23 [2,] 27 1 [[2]] [,1] [,2] [1,] 1 21 [2,] 21 1 [[3]] [,1] [,2] [1,] 1 29 [2,] 23 1 [[4]] [,1] [,2] [1,] 1 25 [2,] 20 1 [[5]] [,1] [,2] [1,] 1 23 [2,]
2010 Mar 11
1
combinations/ indexing a matrix
For a package application, I want to generate all 1-way, or 2-way, ... combinations of factors, symbolically, as a matrix. E.g., all two-way terms among 4 factors. > factors <- LETTERS[1:4] > combn(4,2) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 1 1 2 2 3 [2,] 2 3 4 3 4 4 But I want to replace the numbers I in the above by factors[I]. I know I
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 <-
2006 Jun 21
3
sort matrix by sum of columns
Hi all, I would like to know how can I sort the cols of a matrix by the sum of their elements. a <- matrix(as.integer(rnorm(25,4,2)),10,5) colnames(a) = c("alfa","bravo","charlie","delta","echo") I guess I should use colSums, and then rearrange the matrix somehow according to the result. My idea is to display a "sorted" barplot:
2007 Apr 10
1
R CMD Rdconv drops sections: arguments, seealso, examples (PR#9606)
I've created a .Rd file (below), then converted that to .sgml using R CMD Rdconv --type=Ssgm combn.Rd > combn.sgml The output (shown below) is missing some of the sections: arguments seealso examples If instead I convert to .d (below), the same sections are missing, and the "note" section is included but without the necessary newline.
2012 Mar 09
2
(Fisher) Randomization Test for Matched Pairs: Permutation Data Setup Based on Signs
Hi, I am currently attempting to write a small program for a randomization test (based on rank/combination) for matched pairs. If you will please allow me to introduce you to some background information regarding the test prior to my question at hand, or you may skip down to the bold portion for my issue. There are two sample sizes; the data, as I am sure you guessed, is matched into pairs and
2010 Mar 26
2
More efficient alternative to combn()?
Hi, i am working on a problem where i need to compute the products of all possible combinations of size m of the elements of a vector. I know that this can be achieved using the function combn(), e.g.: > vector <- 1:6 > combn(x = vector, m = 3, FUN = function(y) prod(y)) In my case the vector has 2000 elements and i need to compute the values specified above for m = 32. Using combn() i
2007 Apr 20
1
simply this loop?
Hi, anyone interested in this: I tried to simply this loop with lapply or something but haven't figured it out: mapt = c("203929_s_at", "203930_s_at", "203928_x_at", "206401_s_at") mapt.combn <- lapply(1:4, function(i) combn(mapt, i)) out = list() k = 1 for (i in 1:length(mapt.combn)){ for (j in 1:ncol(mapt.combn[[i]])){ out[[k]] =
2009 Jan 28
2
Logical subset of the columns in a dataframe
Hi R-helpers, I've been struggling with a problem for most of the day (!) so am finally resorting to R-help. I would like to subset the columns of my dataframe based on the frequency with which the columns contain non-zero values. For example, let's say that I want to retain only those columns which contain non-zero values in at least 1% of their rows. In Excel I would calculate a row
2005 Aug 17
2
Copying rows from a matrix using a vector of indices
Hi, I am trying to use a vector of indices to select some rows from a matrix. But before I can do that I somehow need to convert 'combinations' into a list, since 'mode(combinations)' says it's 'numerical'. Any idea how I can do that? library("combinat") combinations <- t(combn(8,2)) indices <- c(sample(1:length(combinations),10)) # convert ???
2012 Feb 14
1
help with matrix column cleaning
Dear R Group I have a matrix object in R, where i want to retain only those columns which have each row from a different group.. see the example below.. team1<-c("a1","a2","b1","b2","b3","c1","c2") teams<-combn(team1, 3) I want a function which will delete all columns in the teams matrix that have more than 1 row
2012 Nov 16
1
pairing data using combn with criteria
Dear All, I have a dataframe made up of individual beetles consisting of individual number, family number, mother's family number, father's family number, and sex of the beetle. I would like to pair up the individuals for breeding. I would, however, like to avoid breeding beetles of the same sex (obviously), the same family, and with the same mother's family or father's family,
2013 Sep 06
1
Importing function that is previously imported by other package
Dear developeRs, I encounter the following problem: in the current version of my package FrF2, certain calls to a functioni do not work when package combinat is loaded, because function combn from combinat masks the function from utils that my package uses. I tried to solve this issue by importing function combn into the namespace of FrF2; I don't need to export it, I just want to use it