0

I would like to calculate the RMS of A and B from the following dataset in R:

Var Diff
A  -360
A   361
A  -362
B  -500
B  -647
B   700

I have found a great post about calculating the mean of a subset using the aggregate function here: R: Calculate means for subset of a group.

Is there a way to use the aggregate function to calculate the RMS of a subset? If not, then any other approach would be appreciated. Thanks.

NelsonGon
  • 12,469
  • 5
  • 25
  • 52
Tanjil
  • 168
  • 10

1 Answers1

0

The answer has been provided by GKi:

aggregate(Diff ~ Var, data=dataset, function(Diff) {sqrt(mean((Diff)^2))})

Tanjil
  • 168
  • 10