随笔分类 -  R语言

1 2 3 4 5 ··· 27 下一页
摘要:library("devtools")install_github("dwinter/pafr")library(pafr) 阅读全文
posted @ 2025-12-03 21:10 小鲨鱼2018 阅读(10) 评论(0) 推荐(0)
摘要:001、R语言自带的包 install.package("ggpplot2") 002、bioconductor if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocMan 阅读全文
posted @ 2025-11-28 18:54 小鲨鱼2018 阅读(12) 评论(0) 推荐(1)
摘要:001、 dat <- c("genome3_genomic.fna", "genome1_genomic.fna", "genome2_genomic.fna") ## 测试字符串 dat class(dat) dat sub("_genomic.fna", "", dat) ## 删除字符串向量 阅读全文
posted @ 2025-11-26 15:32 小鲨鱼2018 阅读(7) 评论(0) 推荐(0)
摘要:001、累计求和 > a <- c(3,4,2, 10, 7) > a [1] 3 4 2 10 7 > cumsum(a) [1] 3 7 9 19 26 。 阅读全文
posted @ 2025-11-24 10:42 小鲨鱼2018 阅读(11) 评论(0) 推荐(0)
摘要:R语言中绘制外围色重内层色前的三角形: library(ggplot2) df <- data.frame( x = c(1, 2, 3, 4, 5), y = c(2, 1, 3, 5, 4) ) ggplot(df, aes(x = x, y = y)) + geom_point( shape 阅读全文
posted @ 2025-09-24 20:17 小鲨鱼2018 阅读(16) 评论(0) 推荐(0)
摘要:001、 dat <- data.frame(a = 1:4, b= 5:8, c = 11:14, d = 15:18, row.names = paste0("sample", 1:4)) dat ## 测试数据框 library(tibble) dat2 <- rownames_to_colu 阅读全文
posted @ 2025-08-12 21:35 小鲨鱼2018 阅读(19) 评论(0) 推荐(0)
摘要:001、基础函数 dat <- data.frame(a = 1:4, b = letters[1:4]) ## 测试数据框 rownames(dat) <- paste0("sample",1:4) ## 命名行名 dat <- cbind(samples = rownames(dat), dat 阅读全文
posted @ 2025-08-12 20:01 小鲨鱼2018 阅读(73) 评论(0) 推荐(0)
摘要:R语言中mutate函数 001、 举例1, 向数据框中添加新列 library(dplyr) dat <- data.frame( a = 1:5, b = 11:15, c = 101:105) ## 测试数据框 dat mutate(dat, new_col = "xx") ## 利用muta 阅读全文
posted @ 2025-07-26 16:48 小鲨鱼2018 阅读(53) 评论(0) 推荐(0)
摘要:001、 x <- c(1, 10, 80, 8, 5, 6, 7) ## 测试向量 F <- ecdf(x) ## ecdf函数 F(3) ## 表示向量x中小于等于3的比例 1/7 sum(x <= 3)/length(x) 。 002、 x <- c(1, 10, 80, 8, 5, 6, 7 阅读全文
posted @ 2025-07-24 23:30 小鲨鱼2018 阅读(31) 评论(0) 推荐(0)
摘要:001、 layout(matrix(c(2,0,1,3), 2, 2, byrow = T), widths = c(5, 2), heights = c(2,5)) ## 设置画板布局 par(mar = c(2, 2, 2, 2)) plot(1:10, cex = 2, pch = 19, 阅读全文
posted @ 2025-07-24 17:03 小鲨鱼2018 阅读(17) 评论(0) 推荐(0)
摘要:001、 默认调色板 palette("default") palette() plot(1:5, cex = 5, pch = 15, col = 1:5) 002、修改默认调色板 palette(c("red", "black", "green","cyan", "purple")) palet 阅读全文
posted @ 2025-07-24 16:15 小鲨鱼2018 阅读(53) 评论(0) 推荐(0)
摘要:001、默认情况下,read.table函数以“#” 为注释行,读取数据时,将忽略掉以“#”号开头的行: 测试数据如下: fst <- read.table("test.txt", sep="\t", header=T) ## 数据读取结果默认忽略掉了注释行 fst 。 002、使用comment. 阅读全文
posted @ 2025-07-24 11:33 小鲨鱼2018 阅读(47) 评论(0) 推荐(0)
摘要:unlink("nonwhite_white_xp_ehh_tmp_result.txt") 阅读全文
posted @ 2025-07-22 11:35 小鲨鱼2018 阅读(6) 评论(0) 推荐(0)
摘要:001、 plot(1:10, main=expression(theta)) 阅读全文
posted @ 2025-07-20 16:04 小鲨鱼2018 阅读(17) 评论(0) 推荐(0)
摘要:001、 # 加载必要的包 library(ggplot2) library(scatterpie) library(maps) # 取世界地图 world <- map_data("world") # 模拟三个地点的数据(经纬度 + 三种成分) df <- data.frame( lon = c( 阅读全文
posted @ 2025-04-26 16:23 小鲨鱼2018 阅读(79) 评论(0) 推荐(0)
摘要:R语言实现矩阵形式于三列表形式的相互转换。 阅读全文
posted @ 2025-04-22 20:53 小鲨鱼2018 阅读(8) 评论(0) 推荐(0)
摘要:001、 dat <- 31:50 rank(-dat, ties.method="average") / length(dat) 。 阅读全文
posted @ 2025-04-20 16:39 小鲨鱼2018 阅读(10) 评论(0) 推荐(0)
摘要:001、pt.cex=3.5 选项 legend("bottomright",legend=c(paste0(" Selected region (","wild",")"), paste0(" Selected region (","cultivated",")")), pch=21,col=c( 阅读全文
posted @ 2025-04-09 20:45 小鲨鱼2018 阅读(73) 评论(0) 推荐(0)
摘要:001、 plot(1:10, xlab = expression(pi)) 。 阅读全文
posted @ 2025-04-09 20:21 小鲨鱼2018 阅读(13) 评论(0) 推荐(0)
摘要:001、R语言中bquote函数用于生成表达式,它允许在表达式中动态插入变量或计算结果。(允许在表达式中动态插入变量或者计算结果) x <- 5 y <- 10 bquote("xxxx" == .(x)) ## bquote函数用于生成表达式,允许在表达式中动态插入变量和计算结果;如变量x, 计算 阅读全文
posted @ 2025-04-09 19:35 小鲨鱼2018 阅读(47) 评论(0) 推荐(0)

1 2 3 4 5 ··· 27 下一页