- 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
推薦閱讀
- Cinema 4D R13 Cookbook
- SCRATCH與機(jī)器人
- 計算機(jī)應(yīng)用復(fù)習(xí)與練習(xí)
- Learning Social Media Analytics with R
- 大數(shù)據(jù)技術(shù)與應(yīng)用
- Windows 7寶典
- Hadoop應(yīng)用開發(fā)基礎(chǔ)
- Excel 2010函數(shù)與公式速查手冊
- 常用傳感器技術(shù)及應(yīng)用(第2版)
- Raspberry Pi Projects for Kids
- Internet of Things with Raspberry Pi 3
- 傳感器原理及應(yīng)用(第二版)
- VMware vSphere 6.5 Cookbook(Third Edition)
- 數(shù)據(jù)庫技術(shù):Access 2003·計算機(jī)網(wǎng)絡(luò)技術(shù)
- Learning VMware App Volumes