摘要: R语言中求分位数 1、测试1 test <- 1:10 test a <- quantile(test,c(0.25,0.75)) a 阅读全文
posted @ 2021-04-23 23:31 小鲨鱼2018 阅读(2539) 评论(0) 推荐(0) 编辑
摘要: R语言中求值域 1、测试1 test <- c(34,3,9,24,43,87,2) test range(test) ## 求值域 diff(range(test)) ## 求最大值和最小值之差 阅读全文
posted @ 2021-04-23 23:23 小鲨鱼2018 阅读(268) 评论(0) 推荐(0) 编辑
摘要: R语言中diff函数,表示滞后差分 1、测试1 test <- sample(1:10,5) test a <- diff(test) ## diff表示后一个数减去前一个数 a 2、测试2 test <- sample(1:10,5) test a <- diff(test) a b <- dif 阅读全文
posted @ 2021-04-23 23:04 小鲨鱼2018 阅读(8781) 评论(0) 推荐(0) 编辑
摘要: 1、测试数据 [root@centos7 test3]# cat b.txt e t s e s g m x w d g i d t e g x g e w 2、打印匹配w的行 [root@centos7 test3]# cat b.txt e t s e s g m x w d g i d t e 阅读全文
posted @ 2021-04-23 18:01 小鲨鱼2018 阅读(1318) 评论(0) 推荐(0) 编辑
摘要: R语言中subset函数同时依据行列进行数据筛选 1、测试数据 manager <- 1:5 date <- c("10/24/08","10/28/08","10/1/08","10/12/08","5/1/09") country <- c("US","US","UK","UK","UK") g 阅读全文
posted @ 2021-04-23 13:00 小鲨鱼2018 阅读(1428) 评论(0) 推荐(0) 编辑
摘要: R语言中根据日期筛选数据 1、测试数据 manager <- 1:5 date <- c("10/24/08","10/28/08","10/1/08","10/12/08","5/1/09") country <- c("US","US","UK","UK","UK") gender <- c(" 阅读全文
posted @ 2021-04-23 12:41 小鲨鱼2018 阅读(4535) 评论(0) 推荐(0) 编辑
摘要: 1、测试1 a <- c(3,7,4,1) order(a) ## 返回从小到大排序的索引 rank(a) ## 返回元素从小到大的排名 sort(a) ## 直接对元素从小到大排序 阅读全文
posted @ 2021-04-23 10:58 小鲨鱼2018 阅读(713) 评论(0) 推荐(0) 编辑
摘要: 1、判断数据类型 a <- 1:4 class(a) is.numeric(a) is.vector(a) is.character(a) is.logical(a) is.array(a) is.data.frame(a) is.matrix(a) is.factor(a) 2、转换数据类型 a 阅读全文
posted @ 2021-04-23 10:45 小鲨鱼2018 阅读(4318) 评论(0) 推荐(0) 编辑
摘要: 1、字符串转换为日期 x <- c("3/5/2004","5/2/2008") y <- as.Date(x,"%m/%d/%Y") y class(y) 2、获取当前日期 Sys.Date() date() 3、日期计算差值 a <- as.Date("2021-03-30") b <- as. 阅读全文
posted @ 2021-04-23 10:35 小鲨鱼2018 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1、查看缺失值 > x <- c(3,1,NA,NA) > x <- c(3,1,NA,NA) > y <- c(3,4,2,7) > z <- c(3,2,5,1) > da <- data.frame(x,y,z) > da x y z 1 3 3 3 2 1 4 2 3 NA 2 5 4 NA 阅读全文
posted @ 2021-04-23 09:19 小鲨鱼2018 阅读(870) 评论(0) 推荐(0) 编辑