Info
- Speaker: Peng Zhao (Department of Health and Environmental Sciences, Xi’an Jiaotong-Liverpool University)
- Time: 13:30 – 15:00, Dec. 8 (Wednesday) 2021
- On-site: ES211, South Campus of XJTLU
- Online: BBB, Access Code: 560567
Prequisites
Knowledge in R. We assume that you have fundamental knowledge in R (e.g. you have taken part in the XJTLU Library’s previous training for R beginners). If not, this training might not suit you well.
Installation. The PCs in the computer room are ready with R and RStudio. If you use your own computer, R must be installed, and RStudio is recommended.
Packages. For saving time, run the following code in R before the training (if you are using the public PCs, please arrive 5 minutes earlier and do it):
install.packages(c('beginr', 'ggplot2','Rcmdr', 'ggplotgui', 'GrapheR', 'plotly', 'GGally', 'remotes', 'MSG', 'fun'))
remotes::install_github(c('pzhaonet/fecitr', 'pzhaonet/mindr'))
- Data. Download the data file participants.csv for the following examples.
Why R and why not R
plot(0, 0, col = "hotpink", pch = 169, font = 5, cex = 50)
text(0, 0, "XJTLU Library", cex = 2)
points(c(-0.8, -0.5, 0.5, 0.8), c(0.5, -0.5, -0.5, 0.5), pch = 169, font = 5, col = "red", bg = "red")
demo("ChinaHeart3D", package = "fun")
Show time
-
- Demo: Violin plot
- Demo: Interactive map (Example)
Graphical User Interface
- The GrapheR package
library(GrapheR)
run.GrapheR()
- The Rcmdr package
library(Rcmdr)
- The ggplotgui package
ggplotgui::ggplot_shiny()
The Deducer package
library(Deducer)
JGR()
Programming
- Basic system
x <- iris$Sepal.Length
y <- iris$Sepal.Width
plot(x, y)
- The ggplot2 package
library(ggplot2)
ggplot(iris) + geom_point(aes(Sepal.Length, Sepal.Width))
library(beginr)
plotpch()
plotcolors()
- The fecitr package
fecitr::plot_summary(iris, base = "hist", if_box = TRUE)
- The GGally package
library(GGally)
ggpairs(iris, aes(fill = Species, alpha = 0.1))
library(MSG)
Sys.setlocale("LC_CTYPE", "Chinese")
msg("3.11")
Further readings
- Learning R and Modern Statistical Graphs
- *Data visualisation* in R for Data Science
- Graphing Data with R
Homework
- What are the differences between plotting graphs with R and with Excel? Compare the pros and cons.
- What do you think about the role graphs play in your study/research?