Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report