当前位置:网站首页>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
边栏推荐
- OAuth2:资源服务器
- Motion capture system for end-positioning control of flexible manipulators
- Open Inventor 10.12 Major Improvements - Harmony Edition
- MySQL [aggregate function]
- jvm 一之 类加载器
- 动作捕捉系统用于柔性机械臂的末端定位控制
- 最近很火的国产接口神器Apipost体验
- The use of thread pool two
- Unity study notes Description of AVPro video jump function (Seeking)
- AWS implements scheduled tasks - Lambda+EventBridge
猜你喜欢

Node version switching management using NVM

Description of Hikvision camera streaming RTSP address rules

Shang Silicon Valley-JVM-Memory and Garbage Collection (P1~P203)

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

Analysis of the startup source code of hyperf (2) - how the request reaches the controller

Linux bash: redis-server: command not found

Resolved (pymysqL connect to the database error) pymysqL. Err. ProgrammingError: (1146, "Table" test. Students' doesn 't exist ")

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

2021 OWASP TOP 10 漏洞指南

Redis与分布式:集群搭建
随机推荐
Shell项目实战1.系统性能分析
Node version switching management using NVM
Detailed guide to compare two tables using natural full join in SQL
什么是消息队列呢?
1小时直播招募令:行业大咖干货分享,企业报名开启丨量子位·视点
/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件的作用
Introduction to BigDecimal, common methods
C# using ComboBox control
MySQL 23 classic interviews hang the interviewer
jvm 一之 类加载器
Uniapp WeChat small application reference standard components
MySql总结
leetcode:2032. Values that appear in at least two arrays
The paper manual becomes 3D animation in seconds, the latest research of Wu Jiajun of Stanford University, selected for ECCV 2022
龟速乘【模板】
leetcode:2032. 至少在两个数组中出现的值
[QNX Hypervisor 2.2用户手册]9.14 safety
I summed up the bad MySQL interview questions
技能大赛训练题: 子网掩码划分案例
49.【拷贝构造函数与重载】