- 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
推薦閱讀
- Internet接入·網(wǎng)絡(luò)安全
- 自動(dòng)檢測與轉(zhuǎn)換技術(shù)
- 流處理器研究與設(shè)計(jì)
- Python Data Science Essentials
- Photoshop CS3特效處理融會(huì)貫通
- PyTorch Deep Learning Hands-On
- Cloudera Administration Handbook
- 大數(shù)據(jù)驅(qū)動(dòng)的設(shè)備健康預(yù)測及維護(hù)決策優(yōu)化
- Prometheus監(jiān)控實(shí)戰(zhàn)
- 電氣控制與PLC原理及應(yīng)用(歐姆龍機(jī)型)
- Mastering Ceph
- Mastering Ansible(Second Edition)
- 菜鳥起飛電腦組裝·維護(hù)與故障排查
- Learning Couchbase
- Appcelerator Titanium Smartphone App Development Cookbook(Second Edition)