subset

[R] How do you select multiple variables from a matrix using a randomly selected vector of column indices?

Hopefully this has an easy answer I just haven't been able to find: I am trying to write a simulation that will compare a number of statistical procedures on different subsets of rows (subjects) and columns (variables) of a large matrix. Subsets of rows was fairly easy using a sample() of the subject ID numbers, but I am running into a...

R - Sorting and Sub-setting Maximum Values within Columns

I am trying to iteratively sort data within columns to extract N maximum values. My data is set up with the first and second columns containing occupation titles and codes, and all of the rest of the columns containing comparative values (in this case location quotients that had to be previously calculated for each city) for those occu...

Bounded Knapsack Problem set-up. Want: a list of all possible packings

Rather than optimize anything, I want to list all the possible - including "incomplete" - packings of the knapsack. Of course, I could loop through all subsets of the set of objects and pick the ones satisfying the weight constraint (can be improved by placing an upper bound on the size of the subsets to look through), but I'd really lik...

Sort a list according to order defined by another list

How can I sort the elements of the list A so that they follow the ordering of another (superset) list B? Assume no duplicates. E.g. A might contain [8 2 5 1] and B might contain [5 6 9 8 7 4 1 2 3], and so I'd like to sort A to become [5 8 1 2] I'm interested in ways of doing this efficiently and with good runtime complexity. ...

C# Hashtable template match

Which is the best way to determine whether a Hashtable contains all keys/values of another Hashtable ? This can also be interpreted as: how to determine whether a Hashtable is a subset of another Hashtable. ...

checking for a subset in android application

So I have an array of strings (let's call it array1) and then I have another array (array2 say) and I want to check if array2 is a subset of array1.. is there a simple command for that? edit: scenario2 I have array1 (which is user generated through an edittext with strings say names of people) and I have a matrix that I want to check ...

In R, how can I take a subset of columns of a data frame and then eliminate duplicate rows?

Imagine I have a data frame with data like this: A | B | C ---+---+--- 1 | 2 | a 1 | 2 | b 5 | 5 | a 5 | 5 | b I want to take only columns A and B, and I want to remove any rows that have become duplicates as a result of eliminating all other columns (that is, column C). So my desied result for the table above would be: A | B -...

find a subset of numbers that most closely match a sum

I'm looking for a technique or algorithm that will give me a subset of integers from a given set that, when summed, most closely match a given target number. I have a music video and I want video for 248 frames. I have a set of clips of various lengths, all less than 248. I would like a subset of those that are closest to 248 when thei...

Finding minimum subset of objects with atributes.

I have algorithmic problem. I don't know how to solve it. Maybe someone can help me? I have objects. Each object has the same features. It could be illustrated in table: Feature1 Feature2 Feature3 Feature4 Object1 1 0 1 1 Object2 0 0 0 ...

Subsetting data in python

Hi, I want to use the equivalent of the subset command in R for some python code I am writing. Here is my data: col1 col2 col3 col4 col5 100002 2006 1.1 0.01 6352 100002 2006 1.2 0.84 304518 100002 2006 2 1.52 148219 100002 2007 1.1 0.01 6292 10002 2006 1.1 0.01 5968 10002 2006 1....

Extract large Matlab dataset subsets

Referencing and assigning a subset of a matlab dataset appears to be extremely inefficient and possibly scales like rows^2 Example: alldata is a large dataset of mixed data - say 150,000 rows by 25 columns (integer, boolean and string). The format for the dataset is: 'format', '%s%u%u%u%u%u%s%s%s%s%s%s%s%u%u%u%u%s%u%s%s%u%s%s%s%s%u...

equal k subsets algorithm

hi, does anyone know a good and efficient algorithm for equal k subsets algorithm ? preferably c or c++ which could handle a 100 element vector maybe with a complexity and time estimation ex. 9 element vector x = {2,4,5,6,8,9,11,13,14} i need to generate all k=3 disjoint subsets with sum = 24 the algorithm should check if there are ...

Classify or cut dataframe by list of class range and summarize it with ddply

I have question about ddply and subset. I have dataframe df like this : df <- read.table(textConnection( " id v_idn v_seed v_time v_pop v_rank v_perco 1 15 125648 0 150 1 15 2 17 125648 0 120 2 5 3 18 125648 0 100 3 6 4 52 125648 0 25 4 ...

How to remove all proper subsets?

Given a list of sets... var sets = new List<HashSet<int>>(numTags); How can I remove all the sets that are a proper subset of another? Is this the best way to do it? for (int i = 0; i < sets.Count; ++i) { for (int j = 0; j < sets.Count; ++j) { if (i != j && sets[i].IsProperSubsetOf(sets[j])) { se...

Ruby: Array contained in Array, any order

Suppose I have the following Ruby code: array_1 = ['a', 'b'] array_2 = ['a', 'b', 'c'] some_function(array_1, array_2) # => True some_function(array_2, array_1) # => False some_function(['a', 'b'], ['a', 'd']) # => False some_function(['x', 'y'], array_2) # => False I am pretty much looking for some_function to return True when Param...

How to export consistent subset of database

Hi, I'm certain that there must already be a many tools "out there" to do this, but I'm not having much luck tracking them down. I'd greatly appreciate your help. We have pretty big MySQL database, with many tables and some complex table relationships enforced via foreign key constraints. What we need is, to create another, smaller dat...

Intensional and extensional definition of sets

Hi, I am searching for a extensional definition for the following set: E := { m | m subset {a,b,c,d} and |m| = 2} My idea is E := {{a,b}, {a,c}, {a,d}, {b,c}, {b,d}, {c,d}, {a,a}, {b,b}, {c,c}, {d,d}} any ideas? ...