Top "Subset" questions

A subset consists of those elements selected from a larger set of elements, by their position in the larger set or other features, such as their value.

How do I select rows by two criteria in data.table in R

Let's say I have a data.table and I want to select all the rows where the variable x has …

r select subset data.table
Apply function on a subset of columns (.SDcols) whilst applying a different function on another column (within groups)

This is very similar to a question applying a common function to multiple columns of a data.table uning .SDcols …

r data.table subset lapply
Read FASTA into a dataframe and extract subsequences of FASTA file

I have a small fasta file of DNA sequences which looks like this: >NM_000016 700 200 234 ACATATTGGAGGCCGAAACAATGAGGCGTGATCAACTCAGTATATCAC >NM_000775 700 124 236 CTAACCTCTCCCAGTGTGGAACCTCTATCTCATGAGAAAGCTGGGATGAG >…

r subset bioinformatics fasta
How to subset matrix to one column, maintain matrix data type, maintain row/column names?

When I subset a matrix to a single column, the result is of class numeric, not matrix (i.e. myMatrix[ , 5 ] …

r matrix subset r-faq
How to select range of columns in a dataframe based on their name and not their indexes?

In a pandas dataframe created like this: import pandas as pd import numpy as np df = pd.DataFrame(np.random.…

r dataframe subset code-conversion
R subsetting a data frame into multiple data frames based on multiple column values

I am trying to subset a data frame, where I get multiple data frames based on multiple column values. Here …

r dataframe subset multiple-columns
Randomly sample a percentage of rows within a data frame

Related to this question. gender <- c("F", "M", "M", "F", "F", "M", "F", "F") age <- c(23, 25, 27, 29, 31, 33, 35, 37) …

r row subset random-sample
Generate all subsets of size k (containing k elements) in Python

I have a set of values and would like to create list of all subsets containing 2 elements. For example, a …

python set tuples subset
Subsets in Prolog

I'm looking for a predicate that works as this: ?- subset([1,2,3], X). X = [] ; X = [1] ; X = [2] ; X = [3] ; X = [1, 2] ; X = [1, 2, 3] ; X = [2, 3] ; ... I've …

list prolog set subset
R gotcha: logical-and operator for combining conditions is & not &&

Why doesn't subset() work with a logical and && operator combining two conditions? > subset(tt, (customer_id==177 &&…

r subset logical-operators