I have a data.table with more than 200 variables which are all binary. I want to create a new column in it that counts the difference between each row and a reference vector:

## New data.table column returns nth largest value in a row

My data looks similar to this:I would like to add a new column rank_match that finds the nth (taken from the rank column) largest value in the row from columns named 1 to 6. For instance, the first line would look for the 3rd largest value in the row from...

## Randomise order of groups in R data table while preserving internal order of groups

In R, I have the following sample data table:Which looks like this:My goal is to randomise the order of groups in the data table x while preserving the internal order of each group.

## Efficient coding to make time increments 'finer' from minutes to seconds in R

I have a time series data with 1 minute increments. I have written a code but with the large amount of data I have (over 1M rows), looping through each line is taking way too long. The data looks something like the below:

## How to make time increments 'finer' from minutes to seconds in R

## Multiple functions over a list of columns and generate new column names automatically with data.table

How to adjust a data table manipulation so that, besides sum per category of several colums, it would also calculate other functions at the same time such as mean and counts (.N) and automatically create column names: "sum c1" , "sum c2", "sum c4" , "mean c1", " mean c2",...

## Calculations based on a dynamic subgroup of a data.table

My question is related to Subset by group with data.table but different.Imagine a data set like this:

## Find variable combinations that makes Primary Key in R

Here is my toy dataframe.How can I get the combination of a minimum number of variables that uniquely identify the observations in the dataframe i.e which variables together can make the primary key?

## What does < stand for in data.table joins with on=

Joining the data tables:via returns the expected result. However, I would expect the line:to returnbecause the keyword on:

## creating new variable that takes into account prior information from the earlier records

I have data as follows and I want to create new variable that takes into account the preceding information in the prior period. For example,