- Hands-On Data Science with R
- Vitor Bianchi Lanzetta Nataraj Dasgupta Ricardo Anjoleto Farias
- 138字
- 2021-06-10 19:12:37
Summarise
The summarise verb is used to obtain aggregate values, generally over a grouped variable.
The following highlights some of the common operations using summarise. Generally, summarise is preceded by a group_by operation, that is, the summary is performed over grouped variables, as shown:
# In the example below: # 1) We sorted the DataFrame by State Name using arrange # 2) We applied a group-by using Region, i.e., all resulting values would be aggregated using Region # 3) We calcuated the values for total rows using n(), the unique states belonging to each region using n_distinct # the max & mean literacy using max and mean respectively # tstate %>% arrange(Name) %>% group_by(Region) %>% summarise(total_rows = n(), first_state = first(Name), unique_states = n_distinct(Name), max_literacy = max(100-Illiteracy), mean_literacy = mean(100-Illiteracy, na.rm=T))
The output is as follows:
推薦閱讀
- Internet接入·網絡安全
- Microsoft Power BI Quick Start Guide
- 嵌入式系統應用
- Getting Started with Clickteam Fusion
- 西門子PLC與InTouch綜合應用
- Getting Started with MariaDB
- SharePoint 2010開發最佳實踐
- 大型數據庫管理系統技術、應用與實例分析:SQL Server 2005
- 樂高機器人—槍械武器庫
- Google SketchUp for Game Design:Beginner's Guide
- Word 2007,Excel 2007辦公應用融會貫通
- Building a BeagleBone Black Super Cluster
- Excel 2007終極技巧金典
- Puppet 3 Beginner’s Guide
- 漢字錄入技能訓練