XJTLU Library Workshop: Modern Statistical Graphs with R

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

  1. 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.

  2. 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.

  3. 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'))
  1. 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

Graphical User Interface

library(GrapheR)
run.GrapheR()
library(Rcmdr)
ggplotgui::ggplot_shiny()

The Deducer package

library(Deducer)
JGR()

Programming

  • Basic system
x <- iris$Sepal.Length
y <- iris$Sepal.Width
plot(x, y)
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)
library(GGally)
ggpairs(iris, aes(fill = Species, alpha = 0.1))
library(MSG)
Sys.setlocale("LC_CTYPE", "Chinese")
msg("3.11")

Further readings

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?

Recording

comments powered by Disqus