subset

Filtering a data frame in R

Hi, let's suppose that I have data frame like expr_value cell_type 1 5.345618 bj fibroblast 2 5.195871 bj fibroblast 3 5.247274 bj fibroblast 4 5.929771 hesc 5 5.873096 hesc 6 5.665857 hesc 7 6.791656 hips 8 7.133673 hips 9 7.574058 hips 10 7.2080...

Collection of sets containing no sets which are a subset of another in the collection

I am looking for an abstract data structure which represents a collection of sets such that no set in the collection is a subset of another set in the collection. This means that on insert the following conditions will be met: A. Inserting an element that is already a subset of another element will return the original collection. B. I...

Subset generation by rules

Let's say that we have a 5000 users in database. User row has sex column, place where he/she was born column and status (married or not married) column. How to generate a random subset (let's say 100 users) that would satisfy these conditions: 40% should be males and 60% - females 50% should be born in USA, 20% born in UK, 20% born in...

Subset Sum TI Basic Programming

I'm trying to program my TI-83 to do a subset sum search. So, given a list of length N, I want to find all lists of given length L, that sum to a given value V. This is a little bit different than the regular subset sum problem because I am only searching for subsets of given lengths, not all lengths, and recursion is not necessarily th...

Sum of the product over all combinations with one element from each group

Given that I have m non-empty distinct sets (labeled Z[ 1 ], Z[ 2 ], ..., Z[ m ]), I aim to compute the sum of all possible subsets where there is exactly one element from each set. The size of each subset is defined to be the product of its members. For example: Z[ 1 ] = {1,2,3} Z[ 2 ] = {4,5} Z[ 3 ] = {7,8} Should result in: 1*4...

Subset whose sum is the smallest sum over a specific threshold

Given a collection of positive integers, I want the subset of those integers whose sum is the smallest sum that exceeds a threshold. ...

R: Applying nlminb to subsets of data (by index or label) and store what the program returns as a new data frame

I was wondering if anyone could kindly help me on this seemingly easy task. I'm using nlminb to conduct optimization and compute some statistics by index. Here's an example from nlminb help. > x <- rnbinom(100, mu = 10, size = 10) > hdev <- function(par) { + -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE)) + } > nlminb(c(9,...

How to get the information and sort, a subset of elements with only identifiers using XSLT?

Hi, I'm new to XSLT and I can't resolve the following problem: I have a xml file like this: <root> <subset> <e id="A"></e> <e id="C"></e> </subset> <data> <info id="A" order="3" name="ANode"></info> <info id="B" order="4" name="BNode"></info> <info id="C" order="1" name="CNode"></inf...

R: Are there any alternatives to loops for subsetting from an optimization standpoint?

A recurring analysis paradigm I encounter in my research is the need to subset based on all different group id values, performing statistical analysis on each group in turn, and putting the results in an output matrix for further processing/summarizing. How I typically do this in R is something like the following: data.mat <- read.c...

R: How to pass a list of selection expressions (strings in this case) to the subset function?

Here is some example data: data = data.frame(series = c("1a", "1b", "1e"), reading = c(0.1, 0.4, 0.6)) > data series reading 1 1a 0.1 2 1b 0.4 3 1e 0.6 Which I can pull out selective single rows using subset: > subset (data, series == "1a") series reading 1 1a 0.1 And pull out multiple rows usin...

Finding the product of each of the (n-1) subsets of a given array

I'm sorry for deleting the original question, here it is: We have a bag or an array of n integers, we need to find the product of each of the (n-1) subsets. e.g: S = {1, 0, 3, 6} ps[1] = 0*3*6 = 0; ps[2] = 1*3*6 = 18; etc. After discussions, we need to take care of the three cases and they are illustrated in the following: 1. S is a se...

Quickly retrieve the subset of properties used in a huge collection in C#

I have a huge Collection (which I can cast as an enumerable using OfType<>()) of objects. Each of these objects has a Category property, which is drawn from a list somewhere else in the application. This Collection can reach sizes of hundreds of items, but it is possible that only, say, 6/30 of the possible Categories are actually used. ...

Filtering subsets using Linq

Hi All, Imagine a have a very long enunumeration, too big to reasonably convert to a list. Imagine also that I want to remove duplicates from the list. Lastly imagine that I know that only a small subset of the initial enumeration could possibly contain duplicates. The last point makes the problem practical. Basically I want to filter ...

SQL Selects on subsets

I need to check if a row exists in a database; however, I am trying to find the way to do this that offers the best performance. This is best summarised with an example. Let's assume I have the following table: dbo.Person( FirstName varchar(50), LastName varchar(50), Company varchar(50) ) Assume this table has millions of rows, howev...

Algorithm: Removing as few elements as possible from a set in order to enforce no subsets

I got a problem which I do not know how to solve: I have a set of sets A = {A_1, A_2, ..., A_n} and I have a set B. The target now is to remove as few elements as possible from B (creating B'), such that, after removing the elements for all 1 <= i <= n, A_i is not a subset of B'. For example, if we have A_1 = {1,2}, A_2 = {1,3,4}, A_3...

What is the better approach to find if a given set is a perfect subset of a set - If given subset is not sorted?

Hi guys, What is the best approach to find if a given set(unsorted) is a perfect subset of a main set. I got to do some validation in my program where I got to compare the clients request set with the registered internal capability set. I thought of doing by having internal capability set sorted(will not change once registered) and do...

subset a data.frame with multiple conditions

Suppose my data looks like this: 2372 Kansas KS2000111 HUMBOLDT, CITY OF ATRAZINE 1.3 05/07/2006 9104 Kansas KS2000111 HUMBOLDT, CITY OF ATRAZINE 0.34 07/23/2006 9212 Kansas KS2000111 HUMBOLDT, CITY OF ATRAZINE 0.33 02/11/2007 2094 Kansas KS2000111 HUMBOLDT, CITY OF ATRAZINE 1.4 05/06/2007 16763 Kansas KS200011...

R error promise already under evaluation when using subset in function but no error in script

I'm getting a strange error when I run the following function: TypeIDs=c(18283,18284,17119,17121,17123,17125,17127,17129,17131,17133,18367,18369,18371,18373,18375,18377,18379) featsave<-function(featfile,TypeIDs=TypeIDs) { mydata1<-read.table(featfile,header=TRUE) mydata2<-subset(mydata1,TypeID %in% TypeIDs) mydata<-as.dat...

How to isolate/retrieve/count a subset of returned records in Rails

Hello all. I'm writing a reports dashboard for a rails app. The dashboard is for user data, and currently it's running multiple count an select queries to build the four or five reports on the page. I'm sure that there is a more efficient way to do this. How would I go about structuring the controller method so that it only runs one ...

Remove rows from a single-column data frame

When I try to remove the last row from a single column data frame, I get a vector back instead of a data frame: > df = data.frame(a=1:10) > df a 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 > df[-(length(df[,1])),] [1] 1 2 3 4 5 6 7 8 9 The behavior I'm looking for is what happens when I use this command on a two-c...