当前位置:网站首页>R HISTOGRAM EXAMPLE QUICK REFERENCE
R HISTOGRAM EXAMPLE QUICK REFERENCE
2022-07-02 09:38:00 【小宇2022】
library(tidyverse)
theme_set(
theme_bw() +
theme(legend.position = "top")
)
head(iris, 3)
iris.gathered <- iris %>%
as_data_frame() %>%
gather(key = "variable", value = "value",
-Sepal.Length, -Species)
head(iris.gathered, 3)
ggplot(iris.gathered, aes(x = value, y = Sepal.Length)) +
geom_point(aes(color = Species)) +
facet_wrap(~variable)+
scale_color_viridis_d()

set.seed(1234)
wdata = data.frame(
sex = factor(rep(c("F", "M"), each=200)),
weight = c(rnorm(200, 55), rnorm(200, 58))
)
head(wdata, 4)
hist(wdata$weight, breaks = 30, col = "steelblue", frame = FALSE)

library(ggplot2)
theme_set(theme_bw())
# Basic plot
ggplot(wdata, aes(x = weight)) +
geom_histogram(bins = 30)
# Change fill color by sex group
ggplot(wdata, aes(x = weight)) +
geom_histogram(aes(fill = sex), bins = 30, alpha = 0.5,
position = position_dodge()) +
scale_fill_viridis_d()

library(ggpubr)
# Basic plots
gghistogram(wdata, x = "weight", fill = "steelblue", alpha = 1)
# Change color by sex group
gghistogram(
wdata, x = "weight", color = "sex",
palette = c("#00AFBB", "#E7B800")
)
边栏推荐
- 程序员成长第六篇:如何选择公司?
- Webauthn - official development document
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
- [cloud native] 2.5 kubernetes core practice (Part 2)
- sqlite 修改列类型
- STM32 single chip microcomputer programming learning
- JS -- take a number randomly from the array every call, and it cannot be the same as the last time
- 函数式接口和方法引用
- 2022年4月17日五心红娘团队收获双份喜报
- TIPC introduction 1
猜你喜欢

PHP tea sales and shopping online store

可昇級合約的原理-DelegateCall

Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'

Tick Data and Resampling

金山云——2023届暑期实习

From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang

JS——每次调用从数组里面随机取一个数,且不能与上一次为同一个

基于Hardhat和Openzeppelin开发可升级合约(一)

Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research

Principe du contrat évolutif - delegatecall
随机推荐
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
webauthn——官方开发文档
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
vant tabs组件选中第一个下划线位置异常
2022年4月17日五心红娘团队收获双份喜报
Jenkins安装
Array splitting (regular thinking
函数式接口和方法引用
每月1号开始计算当月工作日
由粒子加速器产生的反中子形成的白洞
抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
微信小程序利用百度api达成植物识别
Jenkins installation
Precautions for scalable contract solution based on openzeppelin
解决uniapp列表快速滑动页面数据空白问题
制造业数字化转型和精益生产什么关系
Mmrotate rotation target detection framework usage record
The difference between SQL left join main table restrictions written after on and where
Always report errors when connecting to MySQL database
