随笔分类 -  R语言

上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页
摘要:001、 par(mfrow = c(2,2)) plot(1:10, main = 1111) plot(1:10, xlab = pi, main = 2222) plot(1:10, xlab = bquote(pi), main = 3333) ##借助bquote函数输出π plot(1: 阅读全文
posted @ 2023-07-08 22:32 小鲨鱼2018 阅读(377) 评论(0) 推荐(0)
摘要:R 语言中bquote函数用于显示变量的值, 有点类似与shell中的$符号, 主要应用于绘图系统中坐标名称标签的显示。 001、 i = 100 ## 定义一个测试变量 bquote(i) ## 不能直接输出变量的值 bquote(.(i)) ## 需要借助.()的形式输出变量的值 002、应用于 阅读全文
posted @ 2023-07-08 21:59 小鲨鱼2018 阅读(394) 评论(0) 推荐(0)
摘要:001、基础绘图 ggplot(data=mtcars, aes(x=mpg, y=disp, color=factor(cyl))) + geom_point() 02、手动调整颜色 ggplot(data=mtcars, aes(x=mpg, y=disp, color=factor(cyl)) 阅读全文
posted @ 2023-07-02 09:44 小鲨鱼2018 阅读(423) 评论(0) 推荐(0)
摘要:001、删除a、d列 a <- 1:6 b <- 11:16 c <- letters[1:6] d <- LETTERS[1:6] dat <- data.frame(a, b, c, d) dat dat[,!names(dat) %in% c("a","d")] ## 删除a、d列 002、 阅读全文
posted @ 2023-06-19 13:14 小鲨鱼2018 阅读(444) 评论(0) 推荐(0)
摘要:conda create -n py27 python=2.7 conda activate py27 conda install -c conda-forge r-base=4.3.0 R if (!require("BiocManager", quietly = TRUE)) install.p 阅读全文
posted @ 2023-06-07 21:28 小鲨鱼2018 阅读(580) 评论(0) 推荐(0)
摘要:001、代码 dat <- c(3, 8, 2, 9, 4) k <- barplot(dat, axes = FALSE, ylim = c(-4, 10) ,names.arg = FALSE) axis(2, at = seq(0, 10, 2)) label <- paste0("label 阅读全文
posted @ 2023-05-31 00:33 小鲨鱼2018 阅读(867) 评论(0) 推荐(0)
摘要:R语言中cor函数应用与数据框,生成以列为基本单位的两两变量之间的相关的矩阵。 01、测试: a <- c(1, 3, 5, 7, 9) b <- c(3, 8, 7, 12, 23) c <- c(12, 23, 54, 63, 89) d <- c(23, 45, 68, 87, 234) da 阅读全文
posted @ 2023-05-06 14:58 小鲨鱼2018 阅读(387) 评论(0) 推荐(0)
摘要:ctrl + shift + 3 阅读全文
posted @ 2023-05-06 11:06 小鲨鱼2018 阅读(537) 评论(0) 推荐(1)
摘要:R语言中数据框除以向量,规则是数据框中的元素按照列依次递增,除数向量循环递增。 001、 a <- c(20, 10, 6, 8) b <- c(2, 4, 12, 8) c <- c(6, 8, 14, 14) dat <- data.frame(a, b, c) dat idx <- c(2, 阅读全文
posted @ 2023-04-27 16:47 小鲨鱼2018 阅读(152) 评论(0) 推荐(0)
摘要:001、 c1 <- c("a", "b", "a", "a", "b", "c") c2 <- c(3, 1, 4, 7, 8, 2) dat <- data.frame(c1, c2) ## 测试数据框 dat aggregate(dat$c2, by=list(dat$c1), sum) ## 阅读全文
posted @ 2023-04-26 10:21 小鲨鱼2018 阅读(344) 评论(0) 推荐(0)
摘要:001、 library(tidyverse) ## 加载包 a <- c(3, 5, 2, 1) b <- letters[1:4] c <- LETTERS[1:4] dat <- data.frame(a, b, c) dat column_to_rownames(dat, "a") ## 将 阅读全文
posted @ 2023-04-26 10:15 小鲨鱼2018 阅读(12014) 评论(0) 推荐(0)
摘要:001、测试数据框 studentID <- seq(1, 20) gender <- rep(c("M", "M", "F", "F", "F"), 4) math <- rep(c(92, 86, 85, 74, 82), 4) english <- rep(c(76, 69, 82, 71, 阅读全文
posted @ 2023-04-26 09:49 小鲨鱼2018 阅读(338) 评论(0) 推荐(0)
摘要:001、 正常绘图 par(mar=c(6, 6, 6, 6), xpd = TRUE) ## 绘图区域外留白 plot(1:10) legend('right',inset= 0.3, pch=19,legend='xxx') ## 绘图,图例在图形内部 002、图例放在图形正右方 par(mar 阅读全文
posted @ 2023-04-04 15:33 小鲨鱼2018 阅读(857) 评论(0) 推荐(0)
摘要:001、 par(mfrow = c(1,2)) plot(1:10,tck = -0.01, main = "tck = -0.01") ## 保持不变,设置弹tck参数设置刻度线长度 plot(1:10,tck = -0.1, main = "tck = -0.1") 阅读全文
posted @ 2023-04-03 15:16 小鲨鱼2018 阅读(177) 评论(0) 推荐(0)
摘要:001、 .libPaths() 阅读全文
posted @ 2023-03-24 17:33 小鲨鱼2018 阅读(146) 评论(0) 推荐(0)
摘要:001、生成测试子图 library(ggplot2) library(dplyr) ## 依次生成测试子图p1、p2、p3、p4 p1 <- ggplot(mpg) + geom_point(aes(x = displ, y = hwy)) + ggtitle("P1") p2 <- ggplot 阅读全文
posted @ 2023-03-24 16:13 小鲨鱼2018 阅读(186) 评论(0) 推荐(0)
摘要:001、生成几个测试数据 library(ggplot2) library(dplyr) p1 <- ggplot(mpg) + geom_point(aes(x = displ, y = hwy)) + ggtitle("P1") ## 测试图p1 p2 <- ggplot(mpg) + geom 阅读全文
posted @ 2023-03-24 11:55 小鲨鱼2018 阅读(2917) 评论(0) 推荐(0)
摘要:解决方法: 001、在安装目录中手动删除:rlang目录,例如此处windows默认的安装目录:C:\Users\ljx\AppData\Local\R\win-library\4.2;安装目录的获取方法,在终端执行: .libPaths() 002、然后再R中(不是Rstudio)重新安装: in 阅读全文
posted @ 2023-03-24 11:09 小鲨鱼2018 阅读(6552) 评论(0) 推荐(0)
摘要:001、默认绘图 bp <- ggplot(PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() ## 绘图 bp ## 输出图片 002、上部 bp + theme(legend.position="top") ## 放 阅读全文
posted @ 2023-03-23 18:10 小鲨鱼2018 阅读(959) 评论(0) 推荐(0)
摘要:001、正常绘图 library(ggplot2) bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() bp ## 显示绘图结果 002、修改图例标题的名称 bp + scale_fi 阅读全文
posted @ 2023-03-23 17:31 小鲨鱼2018 阅读(4063) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页