Root mean square function in R
29,992
Solution 1
I didn't search for a function but you can write it
x <- 1:10
sqrt(sum(x^2)/length(x))
6.204837
A better alternative is using mean
function
> sqrt(mean(x^2))
[1] 6.204837
Solution 2
The function rms(x)
from the package {seewave}
must produce the same value.
Related videos on Youtube
Author by
Jojo
Updated on July 09, 2022Comments
-
Jojo almost 2 years
A very brief question. After much searching I couldn't find a function to calculate the RMS of a set of integers. Does such a function exist in R?
-
sebastian-c almost 12 yearsYou could even write a function:
RMS <- function(num) sqrt(sum(num^2)/length(num))
;RMS(x)
-
Jojo almost 12 yearsOk thankyou...I'm not sure if it actually exists, which surprises me.