R语言的多线程循环语句
在遇到R里的大量循环操作时,可以考虑多线程处理方式,提高分析速度。具体使用方法针对window与linux/mac平台有所区别。相关笔记如下...
在遇到R里的大量循环操作时,可以考虑多线程处理方式,提高分析速度。具体使用方法针对window与linux/mac平台有所区别。相关笔记如下...
1 2 3 4 5 6 7 8 9 library(tidyverse) # -- Attaching packages ----------------------------------------------------- tidyverse 1.3.1 -- # √ ggplot2 3.3.5 √ purrr 0.3.4 # √ tibble 3.1.2 √ dplyr 1.0.7 # √ tidyr 1.1.3 √ stringr 1.4.0 # √ readr 2.0.0 √ forcats 0.5.1 # -- Conflicts -------------------------------------------------------- tidyverse_conflicts() -- # x dplyr::filter() masks stats::filter() # x dplyr::lag() masks stats::lag() 1、表格筛选 1.1 select...
1 2 library(tidyverse) library(reshape2) 1、matrix 1 2 3 4 5 6 7 8 9 10 11 12 set.seed(123) scores_mt = matrix(round(rnorm(40, mean = 80, sd=10)), nrow = 10, ncol = 4, dimnames = list(paste0("Stu",1:10), paste0("Subject-",LETTERS[1:4]))) class(scores_mt) # [1] "matrix" "array" head(scores_mt) # Subject-A Subject-B Subject-C Subject-D # Stu1 74 92 69 84 # Stu2 78 84 78 77 # Stu3 96 84 70...
ggplot2包一方面可以实现多种形式的数据可视化、比如箱图、柱状图等;另一方面也可以从多个角度进行美化、修饰。对于前者,之前对ggplot...
参考教程:http://www.sthda.com/english/articles/24-ggpubr-publication-ready...
一、ggplot2组图 0、安装包及示例图 1 2 3 4 5 6 7 8 9 10 # #install.packages("devtools") # devtools::install_github("thomasp85/patchwork") library(ggplot2) library(patchwork) p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear)) p3 <- ggplot(mtcars) + geom_bar(aes(gear)) + facet_wrap(~cyl) p4 <- ggplot(mtcars) + geom_bar(aes(carb)) p5 <- ggplot(mtcars) + geom_violin(aes(cyl, mpg, group...
示例数据 3个基因集列表,为list格式 1 2 3 4 5 genes <- paste0("gene",1:1000) set.seed(20210302) gene_list <- list(A = sample(genes,100), B = sample(genes,200), C = sample(genes,300)) 一、VennDiagram VennDiagram包是绘制韦恩图...
一、ggplot绘制基础箱图 0、示例数据 1 2 3 4 5 6 7 8 9 10 11 12 13 library(ggplot2) library(patchwork) #组别名最好是字符型;如果是数值类型,最好转为因子化 ToothGrowth$dose = factor(ToothGrowth$dose) summary(ToothGrowth) # len supp dose #...
1、示例数据 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 library(ggplot2) library(patchwork) library(carData) #示例数据 head(Salaries) #教职工资情况 # rank discipline yrs.since.phd yrs.service sex salary # 1 Prof B 19 18 Male 139750 # 2 Prof B 20 16 Male 173200 # 3 AsstProf B 4 3 Male 79750 #...
1、R中颜色的表示方式 1.1 颜色的名字 R内置了657种颜色的名字可供调用 http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf 1 2 3 4 5 6 7 8 9 10 11 str(colors()) # chr [1:657] "white" "aliceblue" "antiquewhite" ... head(colors()[1:10]) # [1] "white" "aliceblue" "antiquewhite" # [4] "antiquewhite1" "antiquewhite2" "antiquewhite3" set.seed(111) cols = sample(colors(), 5)...