随笔分类 -  R语言

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 27 下一页
摘要:1、基本用法 a <- c(1, 2, 1, 2, 2) b <- c("a", "b", "a", "a", "a") dat <- data.frame(a, b) dat ## 测试数据框 table(dat$a) ## 统计a列中各个元素的频次,即1出现2次,2出现3次 table(dat$ 阅读全文
posted @ 2022-05-24 12:39 小鲨鱼2018 阅读(2691) 评论(0) 推荐(1)
摘要:1、 gender <- rep(c("male", "female"), 2) age <- c(20, 30, 26, 32) height <- c(170, 180, 175, 178) dat <- data.frame(gender, age, height) dat aggregate 阅读全文
posted @ 2022-05-21 18:35 小鲨鱼2018 阅读(151) 评论(0) 推荐(0)
摘要:95%的置信区间? 1、 set.seed(100) a <- rnorm(100) library(car) qqPlot(a, main="qq plot", col="blue", col.lines="red") ## 绘图 阅读全文
posted @ 2022-05-21 14:09 小鲨鱼2018 阅读(965) 评论(0) 推荐(0)
摘要:filter函数的使用需要加载dplyr包 1、 a <- 1:10 b <- sample(10, 10) c <- rep(letters[1:5], each = 2) dat <- data.frame(a, b, c) dat library(dplyr) filter(dat, a < 阅读全文
posted @ 2022-05-21 12:21 小鲨鱼2018 阅读(1539) 评论(0) 推荐(0)
摘要:管道符的作用:将前一个命令的输出作为后一个命令的输入。 管道符命令的使用需要用到dplyr包。 001、在函数中应用 library(dplyr) f1 <- function(x){return(x + 10)} f2 <- function(x){return(x * 2)} ## 首先定义两个 阅读全文
posted @ 2022-05-21 11:36 小鲨鱼2018 阅读(520) 评论(0) 推荐(0)
摘要:1、测试数据 2、读取数据 dir() dat <- read.table("a.txt", fill = T, header = F) ## 增加fill = T参数可以读取列数不一致的数据框 dat dat[dat == ""] = NA ## 将缺失值用NA补充 dat 3、简单处理(求第3行 阅读全文
posted @ 2022-05-20 13:11 小鲨鱼2018 阅读(642) 评论(0) 推荐(0)
摘要:001、par(mgp)选项的作用是调整坐标轴标签、刻度标签、刻度框线距离绘图区域的距离。 par(mfrow = c(2, 2)) par(mgp = c(3, 2, 0)) plot(1:10, main = "3 2 0", cex.main = 3) box(which = "figure" 阅读全文
posted @ 2022-05-18 13:26 小鲨鱼2018 阅读(1903) 评论(0) 推荐(0)
摘要:001、par(mar)选项的作用是调整绘图区域距离外围框线的距离。作用和par(mai)一样, 可能只是单位不一样. par(mfrow = c(2, 2)) par(mar = c(1, 1, 1, 1)) plot(1:10, main = "mar = 1", cex.main = 3) b 阅读全文
posted @ 2022-05-18 13:15 小鲨鱼2018 阅读(8272) 评论(0) 推荐(0)
摘要:001、par(oma)选项的作用是调整外框线距离绘图边界的距离。 par(oma = c(1, 1, 1, 1)) plot(1:10, main = "oma = 1", cex.main = 3) box(which = "figure", lwd = 5) box(which = "plot 阅读全文
posted @ 2022-05-18 13:04 小鲨鱼2018 阅读(1525) 评论(0) 推荐(1)
摘要:001、mai的作用是调整绘图区域与外围框线的距离。 par(mfrow = c(2, 2)) par(mai = c(0.5,0.5,0.5,0.5)) plot(1:10, main = "mai = 0.5", cex.main = 3) box(which = "figure", lwd = 阅读全文
posted @ 2022-05-18 12:57 小鲨鱼2018 阅读(2074) 评论(0) 推荐(0)
摘要:1、 plot(0:10, 0:10, pch = 16, col = "red", xaxs = "i", yaxs = "i") abline(h = 5, lwd = 5) ## 高度 2、 plot(0:10, 0:10, pch = 16, col = "red", xaxs = "i", 阅读全文
posted @ 2022-05-17 23:54 小鲨鱼2018 阅读(701) 评论(0) 推荐(0)
摘要:001 完整代码 dat <- read.table("result.fst", header = T) head(dat) chrlen <- vector() for (i in unique(dat$CHR)) { temp <- dat[dat$CHR == i, ] temp <- tem 阅读全文
posted @ 2022-05-17 13:59 小鲨鱼2018 阅读(335) 评论(0) 推荐(0)
摘要:1、 > plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n") > arrows(x0 = 1, y0 = 1, x1 = 4, y1 = 4) 2、 同时画两个箭头 > plot(1:5, 1:5, xlim = c(0,6), yli 阅读全文
posted @ 2022-05-17 11:20 小鲨鱼2018 阅读(594) 评论(0) 推荐(0)
摘要:1、 > plot(1:10) > segments(1,1, 6, 4, lwd = 5, col = "red") 阅读全文
posted @ 2022-05-17 11:06 小鲨鱼2018 阅读(461) 评论(0) 推荐(0)
摘要:1、 完整代码: dat <- read.table("result.fst", header = T) head(dat) chrlen <- vector() for (i in unique(dat$CHR)) { temp <- dat[dat$CHR == i,] temp <- temp 阅读全文
posted @ 2022-05-17 01:23 小鲨鱼2018 阅读(575) 评论(0) 推荐(0)
摘要:.表示:匹配任意一个字符。 ?表示:匹配前面一个字符0次或者1次。 *表示:匹配前面一个字符0次或者任意多次。 +表示:匹配前面一个字符1次或者任意多次。 .*表示:匹配任意一个字符0次或者任意多次,且为贪婪匹配。 .*?表示:匹配任意一个字符0次或者任意多次, 为非贪婪匹配。 阅读全文
posted @ 2022-05-16 17:49 小鲨鱼2018 阅读(263) 评论(0) 推荐(0)
摘要:+ 表示匹配前面的字符1次或任意多次。 001、R语言中: > sub("a+", "", c("aaaabxa","xxxxbxa")) ##+表示匹配前面的字符1次或任意多次; a+表示匹配a1次或者任意多次 [1] "bxa" "xxxxbx" 002、shell中: root@PC1:/ho 阅读全文
posted @ 2022-05-16 17:44 小鲨鱼2018 阅读(974) 评论(0) 推荐(0)
摘要:?表示匹配前面的字符0次或1次; *表示匹配前面的字符0次或任意多次; 001、在R语言中 > sub("a?b", "", c("aaaabxa","xxxxbxa", "xacb")) ## ?表示匹配前面字符0次或1次; a?b表示匹配b或者ab [1] "aaaxa" "xxxxxa" "x 阅读全文
posted @ 2022-05-16 17:34 小鲨鱼2018 阅读(1486) 评论(0) 推荐(0)
摘要:.*表示贪婪匹配; .*?表示非贪婪匹配; 001、R语言中 > sub("a.*b", "", c("aabab","eabbe")) ##.*表示贪婪匹配,只要满足条件就一直匹配 [1] "" "ee" > sub("a.*?b","",c("aabab","eabbe")) ##.*?表示非贪 阅读全文
posted @ 2022-05-16 17:15 小鲨鱼2018 阅读(2488) 评论(0) 推荐(0)
摘要:1、 .表示匹配任意字符一次; *表示匹配前一个字符0次或任意多次; 001、R语言中: > sub("a.c","",c("abcd", "sdacd", "addfcdf")) ## .表示任意一个字符 [1] "d" "sdacd" "addfcdf" > sub("a*c","",c("ab 阅读全文
posted @ 2022-05-16 16:49 小鲨鱼2018 阅读(1562) 评论(0) 推荐(0)

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 27 下一页