chintan s
chintan s

Reputation: 6488

R custom function on a column and by list

I am trying to understand a piece of code in R and need to confirm my understanding.

The df has following variables: signal, actualPos and neighbour

The code is as follows:

res = df[,calculateDistance(signal), by=list(actualPos, neighbour)]

Does it mean that the data is first grouped by actualPos and neighbour and then the function calculateDistance is applied on signal ?

Upvotes: 0

Views: 64

Answers (1)

JohnSG
JohnSG

Reputation: 1667

This isn't base R, but data.table syntax, which you can confirm by reading the vignettes. Your interpretation seems fine.

Upvotes: 4

Related Questions