- Hands-On Data Science with R
- Vitor Bianchi Lanzetta Nataraj Dasgupta Ricardo Anjoleto Farias
- 116字
- 2021-06-10 19:12:37
Using arrange for sorting
Using arrange method is used to sort datasets as shown as follows:
# Sort the dataset in descending order of Income (high to low) arrange(tstate, desc(Income)) # Sort by Region and Illiteracy (within Region) arrange(tstate, Region, desc(Income)) ## Mutate # The verb mutate is used to add new columns to a dataset, most commonly to represent a calculated value # For instance to find population on a per square mile basis: mutate(tstate, pop_per_sq_mile = Population/Area)
If you want to keep only the newly created variable, use transmute, as shown:
transmute(tstate, pop_per_sq_mile = Population/Area) # # A tibble: 50 x 1 # pop_per_sq_mile # <dbl> # 1 0.0712905261 # 2 0.0006443845 # 3 0.0195032491
推薦閱讀
- Deep Learning Quick Reference
- 腦動力:C語言函數(shù)速查效率手冊
- Python Data Science Essentials
- 深度學(xué)習(xí)中的圖像分類與對抗技術(shù)
- 80x86/Pentium微型計算機原理及應(yīng)用
- VB語言程序設(shè)計
- Arduino &樂高創(chuàng)意機器人制作教程
- Mastering Geospatial Analysis with Python
- 計算機應(yīng)用基礎(chǔ)實訓(xùn)·職業(yè)模塊
- Data Analysis with R(Second Edition)
- EJB JPA數(shù)據(jù)庫持久層開發(fā)實踐詳解
- Flink內(nèi)核原理與實現(xiàn)
- 電機與電力拖動
- Learn SOLIDWORKS 2020
- 數(shù)據(jù)存儲備份與災(zāi)難恢復(fù)