R:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第22行: 第22行:
dev.off()
dev.off()
</syntaxhighlight>
</syntaxhighlight>
== 外部連結 ==
* {{Official|https://www.r-project.org/}} {{en}}
* [https://sweetcode.io/r-apache-log-analysis/ R for Apache Log Analysis: Get It Structured] {{en}}
* [https://www.r-bloggers.com/log-file-analysis-with-r/ Log File Analysis with R] {{en}}
[[Category:軟體]]
[[Category:程式語言]]

2020年12月5日 (六) 09:12的版本

R是一套程式語言,主力在統計運算。

安裝

sudo apt install -y r-base

範例

library(ggplot2)
df <- read.table('blog.gslin.org_ssl-access.log.2.gz')
colnames(df) <- c('host', 'ident', 'authuser', 'date', 'timezone', 'request', 'status', 'bytes', 'referer', 'useragent', 'cipher')
head(df)
df$date=as.POSIXct(df$date, tryFormats=("[%d/%b/%Y:%H:%M:%S"))
head(df)
reqs=as.data.frame(table(df$date))
p <- ggplot(data=reqs, aes(x=as.POSIXct(Var1), y=Freq)) + geom_line() + xlab('Date') + ylab('Requests')
png('a.png', 720, 720)
print(p)
dev.off()

外部連結