随笔分类 - R语言
摘要:001、 library(randomcoloR) palette <- randomColor(count = 54) #随机生成60种颜色,其实里面有重复的 palette <- distinctColorPalette(54) #差异明显的60种 palette plot(1:54, pch
阅读全文
摘要:R语言中数据框中如何实现按照指定列的类别进行排序。 001、 dir() c1 <- rep(c("b","d", "a", "c"), each = 2) c1 c2 <- sample(1:20, 8) c2 dat <- data.frame(c1, c2) ## 生成一个测试数据 idx <
阅读全文
摘要:001、R语言中输出数据框中某一列的字符串长度,并按照字符串的长度进行排序 a <- c("erw", "3s", "errrkk", "r", "r444") b <- letters[1:5] dat <- data.frame(a, b) ## 生成一个测试数据框 dat nchar(dat$
阅读全文
摘要:001、 set.seed(123) group_A <- rnorm(30, mean = 5, sd = 1) # 药物A的效果 group_B <- rnorm(30, mean = 6, sd = 1) # 药物B的效果 u_test_result <- wilcox.test(group_
阅读全文
摘要:001、 df <- data.frame(A = c(1, 2, 3), B = c(4, 5, 6), C = c(7, 8, 9)) row.names(df) <- c("mm", "qq", "dd") df cbind(com1 = rownames(df), df) ## 行号转换为第
阅读全文
摘要:001、 # 创建一个多边形 df <- data.frame( x = c(1, 2, 2, 1, 1.26), y = c(1, 1, 2, 1.6, 1.26) ) df # 绘制多边形 ggplot() + geom_polygon(data = df, aes(x = x, y = y),
阅读全文
摘要:001、frame.plot = T参数绘图 设置是否显示图边框 par(mfrow = c(1,2)) plot(1:10, cex = 3, pch = 19, frame.plot = T, main = "111") ## 显示图边框 plot(1:10, cex = 3, pch = 19
阅读全文
摘要:001、测试01 library(ggplot2) ggplot(data.frame(x = c(1, 3), y = c(1, 3)), aes(x = x, y = y)) + geom_point() + geom_curve(aes(x = 1.5, y = 2.5, xend = 2.6
阅读全文
摘要:001、windows中安装R包,需要编译,调用Rtools报错如下: collect2.exe: error: ld returned 1 exit status no DLL was created ERROR: compilation failed for package 'rgdal' 。
阅读全文
摘要:001、R语言windows中安装R包出现如下报错 Error in system(paste(MAKE, p1(paste("-f", shQuote(makefiles))), "compilers"), : 'make' not found 002、确认是否安装Rtools install.p
阅读全文
摘要:001、R语言read.csv函数发生如下报错: 错误于type.convert.default(data[[i]], as.is = as.is[i], dec = dec, : '<c9>Ϻ<a3>'多字节字符串有错误 002、文件内容 003、 正确做法 > dat2 <- read.csv(
阅读全文
摘要:001、 install.packages("devtools") library("devtools") install_github("lchiffon/REmap")library(REmap) .
阅读全文
摘要:001、R语言中安装maptools出现如下问题: > install.packages("maptools") 将程序包安装入‘C:/Users/liujiaxin/AppData/Local/R/win-library/4.3’ (因为‘lib’没有被指定) Warning in install
阅读全文
摘要:001、R包安装出错如下: ERROR: dependency 'sp' is not available for package 'rgdal' 002、 解决方法: install.packages("sp") 。
阅读全文
摘要:001、R语言中安装 rgdal 出现如下报错 > install.packages("rgdal") 将程序包安装入‘C:/Users/liujiaxin/AppData/Local/R/win-library/4.3’ (因为‘lib’没有被指定) Warning in install.pack
阅读全文
摘要:001、 R语言中如何抽取向量的偶数项或者奇数项 > a <- letters[1:10] ## 生成一个测试向量 > a [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > a[seq(1, length(a), 2)] ## 提取奇数项 [1] "a" "
阅读全文
摘要:001、R语言中根据列明调整数据框中数据的顺序 > a <- 1:4 > b <- 11:14 > c <- letters[1:4] > d <- LETTERS[1:4] > e <- LETTERS[4:1] > dat <- data.frame(b,c,a,e,d) ## 测试数据框 >
阅读全文
摘要:001、 subset函数 > a <- 1:4 > b <- 4:1 > c <- 11:14 > d <- 14:11 > e <- letters[1:4] > dat <- data.frame(a, b, c, d, e) ## 测试数据框 > dat a b c d e 1 1 4 11
阅读全文
摘要:001、正常绘图 plot(1:10, cex = 2, pch = 19) 002、不输出绘图内容 plot(1:10, cex = 2, pch = 19, type = "n") 。
阅读全文