Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The problems and Solutions of calculating the average value of dplyr packets in R language

Shulou Source: shulou.com Published: 2022-06-01 22:07:59 11月27日 Update

Today, I will talk to you about the problems and solutions encountered in the grouping of dplyr packets in R language, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Dplyr in R language, the package group_by () function plus summarise () function is very useful for grouping variance and mean values. For example, a set of data

Df%

Group_by (first)% >%

Summarise (y=mean (second))-> df1

# the result is saved in df1. Enter df1 and run it to return the following

Df1

# A tibble: 2 x 2

First y

1 A 1.5

2 B 3.5

These are normal conditions.

However, I have been having problems with this method recently, and the result is to calculate the average value of 1234 directly, not in groups. This problem has been bothering me for a week. I mentioned it in a tweet on my official account yesterday and left a message to give a solution: the problem caused by the conflict of another package plyr. You can drop plyr detach.

I didn't load the plyr package either, it's probably because I relied on the plyr package to load it at the same time when loading other packages.

Instead of using loaded packages, you can use the detach () function, which is written as

Detach ('package:plyr')

Error: package 'plyr' is required by' Rmisc' so will not be detached when running this command

I said, Rmisc this package has a function to calculate the confidence interval, the average group calculation has not encountered this problem before, this time I want to group calculation confidence interval, so I loaded the Rmisc package. Then close the loaded package at once.

Detach ('package:Rmisc')

Detach ('package:plyr')

In this way, there will be no problem in grouping calculation.

After reading the above, do you have any further understanding of the problems encountered in the grouping of dplyr packets in R language and their solutions? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Problem grouping mean content function language time result method two interval input run code public writing at the same time command average situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology OPPO Reno MariaDB Xiaomi MySQL