本文介绍了如何从CSV计算数据组的RMSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是R的新手,想计算保存在同一.csv文件中的两组数据的RMSE.
I'm new to R and want to calculate the RMSE of two groups of data held within the same .csv file.
.csv包含以下内容:
.csv contains something like this:
Group X Y
A 2 2
A 3 2
B 2 7
B 6 5
我为A组中的那些人尝试检索RMSE的糟糕尝试:
My poor attempt at retrieving the RMSE for just those in Group A:
myData=read.csv("foo.csv")
attach(myData)
library(Metrics)
if (row.names(A)) {
rmse(x,y)
}
在计算RMSE之前,是否需要在数据帧后面附加A和B,还是有更好的方法来实现?
Do I need to append A and B to seperate dataframes before I can calculate RMSE, or is there a better way to achieve this?
提前谢谢!
推荐答案
dplyr
对您可能有用,因为您可以按列中的不同组进行分组.像这样:
dplyr
could be useful for you because you can group by different groups within a column. Something like:
library(dplyr)
myData %>%
group_by(Group) %>%
summarize(RMSE = rmse(x, y))
这篇关于如何从CSV计算数据组的RMSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!