随笔分类 - R语言
摘要:001、正常绘图,显示图例 library(ggplot2) bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() ## 绘图 bp ## 显示绘图 绘图结果如下: 002、隐藏图例的标
阅读全文
摘要:001、直接绘图效果: library(ggplot2) bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() ## 绘图 bp ## 显示绘图结果 绘图结果如下: 002、修改图例显示
阅读全文
摘要:001、 a、利用测试数据绘制箱线图 library(ggplot2) bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() ## 绘图 bp ## 显示绘图结果 绘图结果如下: b、移
阅读全文
摘要:001、使用绘制散点图进行测试。 a、直接绘制散点图 x <- 1:10 y <- seq(1, 1000, 100) dat <- data.frame(x, y) ## 生成测试数据 ggplot(dat, aes(x, y)) + geom_point() ## 直接绘制散点图 绘图结果如下:
阅读全文
摘要:001、 利用绘制散点图进行测试 a、直接绘制散点图 x <- 1:10 y <- seq(1, 1000, 100) dat <- data.frame(x, y) ## 生成测试数据 ggplot(dat, aes(x, y)) + geom_point() ## 直接绘制散点图 绘图结果如下:
阅读全文
摘要:001、theme_classic() 主题用来去除背景 a、使用默认的背景 type <- c('A', 'B', 'C', 'D', 'E', 'F', 'G') nums <- c(10,23,8,33,12,40,60) df <- data.frame(type = type, nums
阅读全文
摘要:001、生成测试数据以及测试 library(ggplot2) x <- paste0("s", 1:16) y <- 4:19 dat <- data.frame(x, y) ## 生成测试数据框 dim(dat) head(dat, 3) ggplot(dat,aes(x,y))+ geom_p
阅读全文
摘要:001、 基础绘图 type <- c('A', 'B', 'C', 'D', 'E', 'F', 'G') nums <- c(10,23,8,33,12,40,60) df <- data.frame(type = type, nums = nums) ## 生成的测试数据框 df ggplot
阅读全文
摘要:001、 factorial(2) ## 计算2的阶乘 factorial(3) ## 计算3的阶乘 factorial(4)
阅读全文
摘要:R语言中exp函数用于返回e的x次方。 exp(2) ## 返回e的二次方 2.718281828459 * 2.718281828459 exp(3) ## 返回e的三次方 2.718281828459 * 2.718281828459 * 2.718281828459
阅读全文
摘要:001、 dat <- c("a", "k", "a", "b", "q") ## 测试字符串向量 grep("a", dat) ## grep匹配字符串,返回索引值 grepl("a", dat) ## grepl匹配字符串, 返回向量中匹配的布尔值
阅读全文
摘要:001、 统计单个元素 a <- c(3, 3 , 3, 2, 7, 2, 3) ## 测试向量 sum(a == 3) ## 统计3在向量中出现的次数 sum(a == 2) 002、 a <- c(3, 3 , 3, 2, 7, 2, 3) table(a) ## 统计所有元素的频次 003、适
阅读全文
摘要:001、下载R安装包:官网 [liujiaxin02@PC1 r_package]$ wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-4/R-4.2.2.tar.gz --no-check-certificate [liujiaxi
阅读全文
摘要:001、问题:conftest.c:1:17: fatal error: jni.h: No such file or directory 002、解决方法, 安装javac [root@PC1 inconsolata]# yum install java-1.8.0-openjdk-devel.x
阅读全文
摘要:001、问题:configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally 002、解决方法 [root@
阅读全文
摘要:001、问题:configure: WARNING: you cannot build PDF versions of the R manuals 002、解决方法 [root@PC1 pcre2-10.37]# yum install texlive 003、测试 [liujiaxin01@PC1
阅读全文
摘要:001、问题:configure: WARNING: you cannot build info or HTML versions of the R manuals 002、解决方法 [root@PC1 pcre2-10.37]# whoami root [root@PC1 pcre2-10.37]
阅读全文
摘要:001、问题:configure: error: PCRE2 library and headers are required, or use --with-pcre1 and PCRE >= 8.32 with UTF-8 support 002、解决方法:安装pcre2库: https://ww
阅读全文
摘要:001、问题:configure: error: "liblzma library and headers are required" 002、解决方法 [root@PC1 curl-7.87.0]# whoami root [root@PC1 curl-7.87.0]# yum install x
阅读全文
摘要:001、问题:checking whether bzip2 support suffices... configure: error: bzip2 library and headers are required 002、解决方法:切回root,安装bzip2-devel [root@PC1 cur
阅读全文

浙公网安备 33010602011771号