R:计算一组子集的RMS

时间:2019-10-08 07:28:16

标签: r aggregate subset

我想从R中的以下数据集中计算A和B的RMS:

protected GraphServiceClient CreateGraphClient()
{
//Get JWT Token via Microsoft.Client.Identity
string accessToken = AccessTokenProvider.GetAuthenticationToken(Permissions);

if (accessToken == null)
{
      throw new InvalidOperationException("Authentication failed.");
}

// Add bearer token to request
IAuthenticationProvider authenticationProvider = CreateAuthenticationProvider(accessToken);
var result = new GraphServiceClient(GraphEndpoints.BetaApi, authenticationProvider)
   {
   PerRequestAuthProvider = () => authenticationProvider
   };

return result;
}

private IAuthenticationProvider CreateAuthenticationProvider(string accessToken)
        {
            var result = new DelegateAuthenticationProvider((requestMessage) =>
            {
                requestMessage.Headers.Authorization = new AuthenticationHeaderValue(CoreConstants.Headers.Bearer, accessToken);
                return Task.FromResult(0);
            });
            return result;
        }

我在这里找到了一篇很棒的文章,关于使用聚合函数计算子集的均值: R: Calculate means for subset of a group

是否可以使用聚合函数来计算子集的RMS? 如果没有,那么任何其他方法将不胜感激。谢谢。

1 个答案:

答案 0 :(得分:0)

答案已由GKi提供:

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