当前位置:网站首页>R语言的画图代码及差异性分析[通俗易懂]
R语言的画图代码及差异性分析[通俗易懂]
2022-07-31 14:25:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
R语言结合统计学方法画图实现
例如:
提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
加载我们常用的包,如ggplot2 , 在这里我只使用R的可视化功能,前期的数据清洗及处理,将数据转化为R可识别的数据格式, 我均是通过Python的pandas包来实现的,强烈推荐使用python清洗数据!!!! 自动化加星号!!!!(显著性!!!!)
提示:以下是本篇文章正文内容,下面案例可供参考
一、ggplot2是什么?
示例:ggplot2 是R语言可视化的一个包,可视化功能非常强大。
二、使用步骤
1.加载我们数据分析及画图所需要的的包
代码如下(示例):
library(xlsx)
library("Hmisc") ## to use "rcorr"
library(psych)
library(lavaan)
library(semTools)
library(haven)
library(ggcorrplot)
library(semPlot)
library(foreign)
library(MASS)
library(tidyr)
library(jtools)
library(dplyr)
library(cluster)
library(fpc)
library(ggplot2)
library(dendextend)
library(purrr)
library(ggpubr) # to use ggplotbar2.读入数据
代码如下(示例):
setwd("F:/课题/数据/处理好的数据/20/")
raw_dt = read.xlsx2("*****.xlsx", sheetIndex = 1)画图代码
箱线图
ggplot(dt1,aes(x=name,y=speed,fill=factor(name))) +
stat_boxplot(geom = 'errorbar')+
geom_boxplot() +
stat_compare_means(label.y=5,method = 'anova') +
labs(title = "你的标题")+
xlab("字符串")
##代码2
boxplot(speed~group_name, dt1, ylab = "speed, m/s",xlab= "A=60,B=40,C=20,单位:min",col = "bisque" )增加显著性标志,加星星
ggplot(dt2,aes(x=Usedtime,y=Trust,fill=factor(Usedtime))) +
geom_boxplot() +
stat_boxplot(geom = 'errorbar')+
stat_compare_means(label.y=5.8,method = 'anova')+
stat_compare_means(comparisons = list(c(1,2),c(1,3),c(1,4),c(2,3),c(2,4),c(3,4)),label.y=c(4.9,5.2,5.5,5.7,5.9,6),label ='p.signif')+
#list(c(1,2),c(1,3)),label.y=c(4.9,5.2,5.5,5.7,5.9,6),label ='p.signif',hide.ns=T)+
labs(title = "特斯拉车主")+
xlab("使用时间")双因素方差分析
双因素方差分析指的是,我们对于想要研究的某个变量,有两个变量会影响。 我这里研究的是驾驶模式(手动/自动)和驾驶时间(长/中/短)对于驾驶绩效的影响。 双因素分析代码
dt1 = read.csv("C:/Users/Heart/Desktop/接管绩效汇总_接管成功_control.csv")
attach(dt1)
aggregate(acc_x,by=list(group_name,control),FUN=mean,na.rm=TRUE)
aggregate(acc_x,by=list(group_name,control),FUN=sd,na.rm=TRUE)
fit_acc_x <- aov(acc_x~group_name*control)
summary(fit_acc_x)总结
提示:这里对文章进行总结:
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128465.html原文链接:https://javaforall.cn
边栏推荐
- Analysis of the startup source code of hyperf (2) - how the request reaches the controller
- 线程池的使用二
- 已解决(pymysqL连接数据库报错)pymysqL.err.ProgrammingError: (1146,“Table ‘test.students‘ doesn‘t exist“)
- uniapp微信小程序引用标准版交易组件
- C语言基础练(九九乘法表)与打印不同星号图案
- Numbers that appear only once in LeetCode
- 49. The copy constructor and overloaded 】
- 3.爬虫之Scrapy框架1安装与使用
- UnityShader入门学习(一)——GPU与Shader
- Spark学习(2)-Spark环境搭建-Local
猜你喜欢

动作捕捉系统用于柔性机械臂的末端定位控制

新款现代帕里斯帝预售开启,安全、舒适一个不落

多智能体协同控制研究中光学动作捕捉与UWB定位技术比较

已解决(pymysqL连接数据库报错)pymysqL.err.ProgrammingError: (1146,“Table ‘test.students‘ doesn‘t exist“)

LeetCode·每日一题·1161.最大层内元素和·层次遍历

OpenShift 4 - 定制 RHACS 安全策略,阻断生产集群使用高风险 Registry

Description of Hikvision camera streaming RTSP address rules

Small test knife: Go reflection helped me convert Excel to Struct

The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%

对数字化时代的企业来说,数据治理难做,但应该去做
随机推荐
C# Get network card information NetworkInterface IPInterfaceProperties
Resnet&API
232层3D闪存芯片来了:单片容量2TB,传输速度提高50%
多智能体协同控制研究中光学动作捕捉与UWB定位技术比较
/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件的作用
龟速乘【模板】
Comparison of Optical Motion Capture and UWB Positioning Technology in Multi-agent Cooperative Control Research
MySQL [subquery]
Shang Silicon Valley-JVM-Memory and Garbage Collection (P1~P203)
Spark学习(3)-Spark环境搭建-Standalone
The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%
C# using ComboBox control
Analysis of the startup source code of hyperf (2) - how the request reaches the controller
Description of Hikvision camera streaming RTSP address rules
使用CompletableFuture进行异步处理业务
SetoolKit User Guide
OAuth2:使用JWT令牌
Prometheus之node_exporter性能监控信息采集含义
UnityShader入门学习(二)——渲染流水线
Unity学习笔记 关于AVPro视频跳转功能(Seeking)的说明