引言:
对于看到过的很棒的R语言学习网站,现予以整理,以待后览
Update:2022-04-03
数据科学中的 R 语言 四川师范大学研究生公选课《数据科学中的R语言》的课程内容,非常的详尽值得学习。
- 建模
- 机器学习
- 探索性数据分析
- 有基础的统计概念简介
- R语言和Python的机器学习
- R语言操作的实例
- R语言可视化ggplot2示例
- cluster analysis
- bookdown,包括了R语言基础,数据分析,Rmarkdown撰写分析报告
- 其中关于可视化讲的很多
- Chord diagram in R with circliz
- ggwordcloud
- Alluviald plot
You can use the following basic syntax to save multiple plots to a PDF in R:
#specify path to save PDF to
destination = 'C:\\Users\\Bob\\Documents\\my_plots.pdf'
#open PDF
pdf(file=destination)
#specify to save plots in 2x2 grid
par(mfrow = c(2,2))
#save plots to PDF
for (i in 1:4) {
x=rnorm(i)
y=rnorm(i)
plot(x, y)
}
#turn off PDF plotting
dev.off()
The following examples show how to use this syntax in practice.
Example 1: Save Multiple Plots to Same Page in PDF
The following code shows how to save several plots to the same page in a PDF:
#specify path to save PDF to
destination = 'C:\\Users\\Bob\\Documents\\my_plots.pdf'
#open PDF
pdf(file=destination)
#specify to save plots in 2x2 grid
par(mfrow = c(2,2))
#save plots to PDF
for (i in 1:4) {
x=rnorm(i)
y=rnorm(i)
plot(x, y)
}
#turn off PDF plotting
dev.off()
Once I navigate to the PDF in the specified location on my computer, I find the following one-page PDF with four plots on it:
Example 2: Save Multiple Plots to Different Pages in PDF
To save multiple plots to different pages in a PDF, I can simply remove the par() function:
#specify path to save PDF to
destination = 'C:\\Users\\Bob\\Documents\\my_plots.pdf'
#open PDF
pdf(file=destination)
#save plots to PDF
for (i in 1:4) {
x=rnorm(i)
y=rnorm(i)
plot(x, y)
}
#turn off PDF plotting
dev.off()
Once I navigate to the PDF in the specified location on my computer, I find the a four-page PDF with one plot on each page.
Additional Resources
How to Use the par() Function in R How to Overlay Plots in R