rmse in r in r

To calculate the RMSE (Root Mean Squared Error) in R, we can use the RMSE function from the Metrics package. Here's an example:

main.r
# Install the Metrics package if not already installed
install.packages("Metrics")

# Load the package
library(Metrics)

# Example vectors of predicted and actual values
actual <- c(10, 15, 20, 25)
predicted <- c(12, 18, 22, 28)

# Calculate RMSE
RMSE(predicted, actual)
271 chars
13 lines

This will output the RMSE value:

main.r
[1] 2.738613
13 chars
2 lines

gistlibby LogSnag