搜索
查看: 655|回复: 0

[R] R FOR DATA SCIENCE

[复制链接]

3

主题

3

帖子

36

积分

新手上路

Rank: 1

积分
36
发表于 2018-10-15 10:32:56 | 显示全部楼层 |阅读模式
library(tidyverse)
library(nycflights13)


#Learing how to use arrange() to arrange orders  
arrange(flights, year, month, day)#arrange by year, month and day



mydata <- tibble(x=c(1,2,NA),y=c(NA,NA,2)) #create a tibbe with NA

mydata

arrange(mydata,desc(is.na(x)))#desc() means re-order by a column in descending order, by using is.na() we can sort NA to the start.

arrange(flights, desc(is.na(dep_time)))
arrange(flights, desc(is.na(dep_time)), dep_time)


arrange(flights,desc(dep_delay))#find the most delayed flight

arrange(flights,dep_delay)#find the earliest flight


arrange(flights,distance / air_time / 60)#find the flight with the shortest flying time
a <- arrange(flights,air_time)#find the flight that traveled the shortest
b <- arrange(flights,desc(air_time))#find the flight that traveled the longest





上一篇:R for data science
下一篇:问题待解决3-有哪些拿来就用的生存分析数据库?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|生信技能树 ( 粤ICP备15016384号  

GMT+8, 2019-12-16 11:32 , Processed in 0.056650 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.