「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()

外部連結