similar to: fast way to compare two matrices of combinations

Displaying 20 results from an estimated 10000 matches similar to: "fast way to compare two matrices of combinations"

2009 Jul 04
4
help with dealing with integer(0) returns from grep used within a conditional loop
I am using grep to locate colnames to automate a report build and have run into a problem when a colname is not found. The use of integer(0) in a conditional statement seems to be a no no as it has length 0. Below is a self-contained trivial example. I would like to get something like "NA" or -1 for the position when it is not found OR learn a way to use integer(0) or some
2008 Sep 24
1
splitting strings efficiently
I have a very long list of strings. Each string actually contains multiple values separated by a semi-colon. I need to turn each string into a vector of the values delimited by the semi-colons. I know I can do this very laboriously by using loops, nchar, and substr, but it is terribly slow. Is there a basic R function that handles this situation? If not, is there perhaps a faster way to do it than
2009 Apr 06
3
how to subsample all possible combinations of n species taken 1:n at a time?
Hello I apologise for the length of this entry but please bear with me. In short: I need a way of subsampling communities from all possible communities of n taxa taken 1:n at a time without having to calculate all possible combinations (because this gives me a memory error - using combn() or expand.grid() at least). Does anyone know of a function? Or can you help me edit the combn or
2008 Mar 12
2
subset list based on logical within element flag
I have a very long list that I'd like to subset based on a logical value within each element. Example below. I'd like to get just those list elements for further study whose $sig.cor slot is TRUE. In this example, I'd only want element [[2]]. Should be simple, I know. How can I do this? Thanks, Mark > gene.pair.tf.lst [[1]] [[1]]$gene.pair [1] "Lgals1:Pxmp2"
2009 Aug 28
1
problems with strsplit using a split of ' \\\ ' : a regex problem
I have a vector of gene symbols, some of which have multiple aliases. In the case of an alias, they are separated by ' \\\ '. Here is a real world example, which would represent one element of my vector: Eif4g2 /// Eif4g2-ps1 /// LOC678831 What I would like to do is input the vector into a function and output a vector with just the first alias of each element (or, if there are no aliases,
2010 Jun 24
1
[OT] Combinatorials wtih constraints
This is not an R question, but a question on some combinatorial mathematics. Apologies for the OT if it is wildy inappropriate. The traditional C(n.k) method tells me how many combinations k I can make with n objects. However, suppose I want the number of combinations where an object cannot be used more than Q times where Q is a parameter that changes? For instance: combn(LETTERS[1:5], 3) shows
2009 Feb 24
3
All the products of common factors
This is a seemingly simple problem - hopefully someone can help. Problem: we have two integers. We want (1) all the common factors, and (2) all the possible products of these factors. We know how to get (1), but can't figure out a general way to get (2). Example: 40 and 80 have these factors: c(1,2,2,2,5) and c(1,2,2,2,2,5). We can use match() to get the common factors c(1,2,2,2,5). What
2012 Mar 28
6
How to get all possible combinations?
Dear all, suppose I have a vector with elements as: Vec <- c(2,3,4,5,6) Now I want to have all possible combination of length 3 using those elements and without any repetition. Like, I want to have 1 possibility like 2-3-4 but not 3-2-4. Can somebody guide me how to achieve that in R? Thanks for your help.
2008 Dec 16
0
[LLVMdev] Another compiler shootout
On Tuesday 16 December 2008 01:03:36 Evan Cheng wrote: > FYI. http://leonardo-m.livejournal.com/73732.html > > If anyone is motivated, please file bugs for the losing cases. Also, > it might make sense to incorporate the tests into our nightly tester > test suite. FWIW, I just ported my ray tracer benchmark to C and found that llvm-gcc gives much worse performance than gcc on x86
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
2011 Nov 04
1
Creating a sequence from two samples with several constraints (frequency and repeats)
I'm attempting to create a sequence for an experiment and am hoping I can use R to create it. It has several constraints: (1) It is made up of two sequences (red and green) that have 4 different repeating triplets (e.g. T1=ABC T2=DEF T3=GHI JKL) (2) Each sequence has the following constraints: (a) there cannot be repeating triplets (e.g. T1 T1), (b) there cannot be repeating triplet pairs
2011 Oct 29
4
R help with different combinations of vectors of different sizes
Hi, I am trying to get different combinations of a vector of different size and find their sum. For example, if I have a vector (i,j) where i and j can be anything from 0 to 5, i get these combinations (0,0), (0,1), (1,0), (1,1), (2,0), ...... (5,5) and find sum of these as 0, 1, 1, 2, ..... , 10. I used outer functions to get this and it worked. What if I have a vector (i,j,k) where all i, j ,
2012 Jun 15
2
strings concatenation and organization (fast)
Hello, What is the fastest way to do this? I has to be done quite a few times. Basically I have sets of 3 numbers (as characters) and sets of 3 dashes and I have to store them in named columns. The order of the sets and the column name they fall under is important. The actual numbers and the pattern/order of the sets should be considered random/unpredictable. Sample data: vec =
2012 Apr 20
1
lines crosses
Hello, If the exact value does not exist in the vector, can I still get at the intersections? Is there a simple way to do this and avoid looping? Seems like there would be a simple R function to do this... Example: vec <- c(5,4,3,2,3,4,5) vec [1] 5 4 3 2 3 4 5 intersect(vec,2.5) numeric(0) I want to get: 2.5 and 2.5 My real data is very large and I don't know the values of anything
2011 Sep 28
1
Multiplying a list of matrices with a vector
Hi all! I have a list of matrices and I want to multiply the ith element of the list with the ith element of a another vector. That is, > LL <- list(A=diag(3),B=diag(3),C=diag(3)) > vec <- 1:3 > for(i in 1:3) + { + LL[[i]] <- LL[[i]]*vec[i] + } > LL $A [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 $B [,1] [,2] [,3] [1,] 2 0
2001 Dec 19
2
how to get unique vectors
First, happy holidays, everyone! Thanks to the R team for bringing out 1.4 before the new year. I have 10000 integer triplets stored in A[1:10000, 1:3]. I would like to find the unique triplets among the 10000 ones with possible duplications. What is the easiest way for this. I know the function unique(), which apply to a vector, not the 10000*3 array in my problem. Thanks in advance. Jason
2009 Aug 24
4
Is there a fast way to do several hundred thousand ANOVA tests?
Dear R users, I have a matrix a and a classification vector b such that > str(a) num [1:50, 1:800000] and > str(b) Factor w/ 3 levels "cond1","cond2","cond3" I'd like to do an anova on all 800000 columns and record the F statistic for each test; I currently do this using f.stat.vec <- numeric(length(a[1,]) for (i in 1:length(a[1,]) { f.test.frame
2003 Sep 22
1
Managing a list with a list
OK. Another amateur question. I have a list with attributes on pine trees, like the stem's location, a logical value set to T if it's alive, some parameters for growth, diameter, etc. The tree list has another list in it which is a new data type for me. I want to make a new list that retains all the live trees. That is where Living == T. Here's the summary of the list: >
2006 Mar 02
1
extracting RGB values from a colorspace class object
Greetings, After pouring over the documentation for the 'colorspace' package, I have not been able to figure out how the plot() method converts colorspace coordinates to RGB values for display on the screen. I am convert between colorspaces with the various as() methods... but cannot seem to find a way to extract RGB (i.e. for displaying on a computer screen) triplets from color space
2013 Apr 24
2
Distance matrices Combinations
Dear UseRs, MY PROBLEM IS A SMALL PIECE OF A REAL BIG AND A COMPLICATED PROBLEM. IF I DELIBERATE IN A VERY SIMPLE WAY THEN ALL I WANT IS TO PUT ALL THE POSSIBLE COMBINATIONS OF 75 DISTANCE MATRICES (BY TAKING 4 MATRICES, MORE COMMONLY 75C4), in the following equation. t<-as.matrix((MAT1)^2+(MAT2)^2+(MAT3)^2+(MAT4)^2+,upper=T,diag=T)) Then "1215450" values of "t"(one for