- 浏览: 2487240 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Rlang(2)Diagram - Model - Loop - Ifelse
1. Generate the Diagram
This will draw the diagram for us.
> plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5", type = "l", ylim = c(0, 200))
> lines(x = pm$time, y = pm$h100, col = "red")
> legend(x = 15, y = 180, legend = c("8 m", "100 m"), col = c("black", "red"), lty = 1)
plot, lines, legend.
These command will open the file and draw the things on the file.
pdf(file ="/opt/data/output1.pdf")
plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5", type = "l", ylim = c(0, 200))
lines(x = pm$time, y = pm$h100, col = "red")
legend(x = 15, y = 180, legend = c("8 m", "100 m"), col = c("black", "red"), lty = 1)
dev.off()
Some complex draw example
plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5 at 8 m", type = "l", ylim = c(0, 200), axes=FALSE)
axis(2)
axis(4)
axis(1, at = 0 : 23, labels = 0 : 23)
points(x = pm$time, y = pm$h100, col = "red", type = "l")
points(x = pm$time, y = pm$h325, col = "blue", type = "l")
abline(h = c(10, 15 , 25, 35), col = "grey", lty = 2)
legend("top", legend = c("8 m", "100 m", "325 m"), col = c("red", "black", "blue"), lty = 1)
box() #
Some function I need to be familiar with. plot, box plot, points(), lines(), lines(), abline(), box(), axis(), legend(), pdf()
2. Modeling
Functions: lm(), nls(), par()
Linear Regression
https://zh.wikipedia.org/zh-cn/%E7%B7%9A%E6%80%A7%E5%9B%9E%E6%AD%B8
http://www.jasongj.com/2015/03/27/ml1_linear_regression/
loss function, error function, cost function
Draw the 4 Plot
mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
pm <- read.csv(file = mydata)
m <- lm(pm$h100 ~ pm$h8)
summary(m)
par(mfrow = c(2,2))
plot(m)
Draw the Line and All the Points
mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
pm <- read.csv(file = mydata)
m <- lm(pm$h100 ~ pm$h8)
summary(m)
par(mfrow = c(1, 1))
plot(pm$h8, pm$h100, cex = 2, pch = 21, bg = "red", col = "green")
abline(m, col = "purple", lwd = 3)
legend("bottomright", pch = c(21, NA), lty = c(NA, 1), legend = c("Data", "Linear fit"),
pt.bg = "red", col = c("green", "purple"), lwd = c(NA, 2))
3. Loop
Draw three plots, based on the different high of the data
> par(mfrow=c(1,3))
> plot(pm[,1], pm[,2], cex=2, type = "l")
> plot(pm[,1], pm[,3], cex=2, type = "l")
> plot(pm[,1], pm[,4], cex=2, type = "l")
The for Loop
par(mfrow=c(1,3))
for (i in c(2, 3, 4)) plot(pm[, 1], pm[, i], cex = 2, type = "l")
Some other useful functions are : for(), while(), until()
() for function, [] for the index of array or seq, {} for code block.
4. Check Statements
[1] FALSE
> 3>2 | 1 > 2
[1] TRUE
> 3>2&!(1>2)
[1] TRUE
That is really powerful
> x <- 1:3
> x == 2
[1] FALSE TRUE FALSE
Define 2 array of numbers
> x <- 6:1
> x
[1] 6 5 4 3 2 1
> y <-c(3,5,7)
> y
[1] 3 5 7
Check if x is in y
> x %in% y
[1] FALSE TRUE FALSE TRUE FALSE FALSE
Find the number in x and also in y
> x[x %in% y]
[1] 5 3
Find their index
> which(x %in% y)
[1] 2 4
Find the max value exist in which time
> mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
> pm <- read.csv(file = mydata)
> pm$time[which(pm$h8 == max(pm$h8))]
[1] 8 9 10
Print is also a useful command in R language
> x <- 12
> if(x<99) print("x is less than 99")
[1] "x is less than 99"
Useful Command ifelse
> x <- 12
> if (x < 99) {
+ print("x is less than 99")
+ } else {
+ print("x is larger than 99")
+ }
[1] "x is less than 99"
> ifelse(x < 99, "small", "large")
[1] "small"
IFELSE can be powerful used in a lot of place
plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5",
cex = ifelse(pm$h8 == max(pm$h8), 2, 1),
pch = 16, type = "b",
col = ifelse(pm$h8 > 75, "red","darkgreen"))
CEX may be related to how big the points will be.
References:
http://dapengde.com/archives/14824
http://dapengde.com/archives/14833
http://dapengde.com/archives/14836
http://dapengde.com/archives/14843
1. Generate the Diagram
This will draw the diagram for us.
> plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5", type = "l", ylim = c(0, 200))
> lines(x = pm$time, y = pm$h100, col = "red")
> legend(x = 15, y = 180, legend = c("8 m", "100 m"), col = c("black", "red"), lty = 1)
plot, lines, legend.
These command will open the file and draw the things on the file.
pdf(file ="/opt/data/output1.pdf")
plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5", type = "l", ylim = c(0, 200))
lines(x = pm$time, y = pm$h100, col = "red")
legend(x = 15, y = 180, legend = c("8 m", "100 m"), col = c("black", "red"), lty = 1)
dev.off()
Some complex draw example
plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5 at 8 m", type = "l", ylim = c(0, 200), axes=FALSE)
axis(2)
axis(4)
axis(1, at = 0 : 23, labels = 0 : 23)
points(x = pm$time, y = pm$h100, col = "red", type = "l")
points(x = pm$time, y = pm$h325, col = "blue", type = "l")
abline(h = c(10, 15 , 25, 35), col = "grey", lty = 2)
legend("top", legend = c("8 m", "100 m", "325 m"), col = c("red", "black", "blue"), lty = 1)
box() #
Some function I need to be familiar with. plot, box plot, points(), lines(), lines(), abline(), box(), axis(), legend(), pdf()
2. Modeling
Functions: lm(), nls(), par()
Linear Regression
https://zh.wikipedia.org/zh-cn/%E7%B7%9A%E6%80%A7%E5%9B%9E%E6%AD%B8
http://www.jasongj.com/2015/03/27/ml1_linear_regression/
loss function, error function, cost function
Draw the 4 Plot
mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
pm <- read.csv(file = mydata)
m <- lm(pm$h100 ~ pm$h8)
summary(m)
par(mfrow = c(2,2))
plot(m)
Draw the Line and All the Points
mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
pm <- read.csv(file = mydata)
m <- lm(pm$h100 ~ pm$h8)
summary(m)
par(mfrow = c(1, 1))
plot(pm$h8, pm$h100, cex = 2, pch = 21, bg = "red", col = "green")
abline(m, col = "purple", lwd = 3)
legend("bottomright", pch = c(21, NA), lty = c(NA, 1), legend = c("Data", "Linear fit"),
pt.bg = "red", col = c("green", "purple"), lwd = c(NA, 2))
3. Loop
Draw three plots, based on the different high of the data
> par(mfrow=c(1,3))
> plot(pm[,1], pm[,2], cex=2, type = "l")
> plot(pm[,1], pm[,3], cex=2, type = "l")
> plot(pm[,1], pm[,4], cex=2, type = "l")
The for Loop
par(mfrow=c(1,3))
for (i in c(2, 3, 4)) plot(pm[, 1], pm[, i], cex = 2, type = "l")
Some other useful functions are : for(), while(), until()
() for function, [] for the index of array or seq, {} for code block.
4. Check Statements
[1] FALSE
> 3>2 | 1 > 2
[1] TRUE
> 3>2&!(1>2)
[1] TRUE
That is really powerful
> x <- 1:3
> x == 2
[1] FALSE TRUE FALSE
Define 2 array of numbers
> x <- 6:1
> x
[1] 6 5 4 3 2 1
> y <-c(3,5,7)
> y
[1] 3 5 7
Check if x is in y
> x %in% y
[1] FALSE TRUE FALSE TRUE FALSE FALSE
Find the number in x and also in y
> x[x %in% y]
[1] 5 3
Find their index
> which(x %in% y)
[1] 2 4
Find the max value exist in which time
> mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
> pm <- read.csv(file = mydata)
> pm$time[which(pm$h8 == max(pm$h8))]
[1] 8 9 10
Print is also a useful command in R language
> x <- 12
> if(x<99) print("x is less than 99")
[1] "x is less than 99"
Useful Command ifelse
> x <- 12
> if (x < 99) {
+ print("x is less than 99")
+ } else {
+ print("x is larger than 99")
+ }
[1] "x is less than 99"
> ifelse(x < 99, "small", "large")
[1] "small"
IFELSE can be powerful used in a lot of place
plot(x = pm$time, y = pm$h8, xlab = "Time", ylab = "PM2.5",
cex = ifelse(pm$h8 == max(pm$h8), 2, 1),
pch = 16, type = "b",
col = ifelse(pm$h8 > 75, "red","darkgreen"))
CEX may be related to how big the points will be.
References:
http://dapengde.com/archives/14824
http://dapengde.com/archives/14833
http://dapengde.com/archives/14836
http://dapengde.com/archives/14843
发表评论
-
Stop Update Here
2020-04-28 09:00 263I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 433NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 312Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 323Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 294Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 381Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 376Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 329Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 400VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 337Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 417NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 363Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 293Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 209GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 392GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 276GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 265Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 261Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 253Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 238Serverless with NodeJS and Tenc ...
相关推荐
rlang, 面向 R 编程的低层 API rlang 重要的: rlang API仍在成熟。 请参见 ?rlang::lifecycle 以获得被认为是稳定的函数列表。概述rlang软件包提供了使用 R 和tidyverse的核心语言功能的工具:系统
rpy2 2017-12-21 rlang; 电阻 2018-02-16 新维; linux 2018-02-03 jupyter; 工作室; 笔记本; 系统 2018-03-08 护目镜; 乌本图 2018-03-19 Python; R; 包裹; 备份; 恢复; 点子; conda 2018-03-19 conda; 点子 ...
都是我在画图中需要用到的包,如有补充欢迎:ggplot2_3.0.0/baidumap-master/bitops_1.0-6/colorspace_1.3-2/crayon_1.3.4/curl_3.2/devtools_1.13.6/digest_0.6.17/gtable_0.2.0/httr_1.3.1/lazyeval_0.2.1/mapdata...
rlang:使用R进行编程的低级API
由于R软件版本问题,一些函数不能运用,在此编写了一个程序包可以使那些函数可以用。
R语言迷你教程 编程是一点点学习的。 您建立在基本概念上。 您将已经拥有的知识转移到另一种语言。 午餐休息课程在短期课程中讲授R(一种用于数据分析和报告的最受欢迎的编程语言),以扩展现有程序员已经知道的知识...
Downloading http://pypi.doubanio.com/packages/69/ca/926f7cd3a2014b16870086b2d0fdc84a9e49473c68a8dff8b57f7c156f43/gunicorn-20.0.4-py2.py3-none-any.whl (77kB) |████████████████████...
三层DLL架构解决方案-示范,值得研究一下
R是用于数据分析的语言,通过Rcpp可以将cpp库引入R中使用,适用于提高性能和接入原有算法库的场合。 Rcpp包提供C++类方便C or C++代码与R软件包进行交互,使用R中提供的.Call() 调用界面。 Rcpp提供R中的基础数据...
Erlang opt_win64 20.2 windows exe 安装包 Erlang 20.2 is the upcoming version of Erlang For Windows x64 installer 截至2018.01.25 groovy最新最稳定版本
安装要从github获取当前的开发版本: git clone https://github.com/bcm-uga/RiTMIC.gitcd RiTMIC R构建包install.packages( " devtools " )# mixtools htmltools scales yaml lazyeval plyr rlang ggplot2 gtools ...
# mixtools htmltools scales yaml lazyeval plyr rlang ggplot2 gtools caTools KernSmooth penda progress devtools :: load_all(); devtools :: document(); devtools :: install() 建立小插图 setwd("vignettes...
A GUIDE TO FUNCTIONAL PROGRAMMING IN E RLANG FOR THE EXPERIENCED PROCEDURAL DEVELOPER.
数据分析和可视化的蘸酱 包装dipsaus提供add-ons到各种软件包,如shiny , rlang , future等,以增强这些软件包。 从Github安装开发版本包, devtools :: install_github( ' dipterix/dipsaus ' ) dipsaus从以下...
library( rlang ) 能够对数据帧执行按行操作很有用。 作为一个简单的示例(显然,在实践中,这些列不应该是列表列,但现在忽略它),这将失败: tibble( a = list ( 10 , 11 ), b = list ( 3 , 4 )) % > % mutate...
ECG是E rlang函数C的所有图G enerator,其自动绘制函数调用和处理程序派生。 ECG利用Erlang强大的跟踪机制和可视化工具graphviz ,确保已安装graphviz ,并且由于此处使用Python绑定,因此还需要安装Digraph软件包。...
library(ggplot2) library(rlang) library(utils) > a<-read_tsv("./Tonsils_RNA_QC.txt") Parsed with column specification: cols( Group = col_character(), SampleID = col_character(), Subject = col_...
两个相关系数的比较[p, z, za, zb] = corr_rtest(ra, rb, na, nb) 灵感来自 Rlang 的 r.test() http://personality-project.org/r/html/r.test.html