Articles by Zhenguo Zhang

[R] tidy evaluation in ggplot2 (part 2)

November 10, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/11/11/r-tidy-evaluation-in-ggplot2-part-2/ - knitr::opts_chunk$set(echo=T, fig.align = "center", fig.width = 6, fig.height = 5, dpi=150, warning=FALSE) library(knitr) library(ggplot2) How to use variables to refe...
[Read more...]

[R] tidy evaluation in ggplot2

October 22, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/10/23/r-tidy-evaluation-in-ggplot2/ - Since ggplot2 version 3.0.0, it started to support tidy evaluation, and use the technique to replace aes_ and aes_string(). In this post, I would like to show how the syntax of ggplot2 ...
[Read more...]

[R] How to overlay points over boxplots

August 25, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/08/26/r-how-to-overlay-points-over-boxplots/ - library(ggplot2) ggplot2 is a powerful tool to visualize data. Today I would like to show how to make a boxplot and then overlay points. A pure boxplot First, let’s make a box...
[Read more...]

[Tutorial] How to create and tune ridgeline density plot using ggridges

June 30, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/07/01/tutorial-how-to-create-and-tune-ridges-density-plot-using-ggridges/ - Today, I would like to introduce how to use the package ggridges to create a ridgeline density plot. Let’s start. Install the package
install.packages("ggridges")
First try
library(ggplot2)
library(ggridges)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
plt<-ggplot(iris, aes(x=Sepal.Width, y=Species, fill=Species))
plt<-plt+theme_bw()
plt+geom_density_ridges()
## Picking joint bandwidth of 0.13
Looks good, right. Add data points To do so, we will add ...
[Read more...]

[Tutorial] How to install Shiny server on Ubuntu 22.04

June 29, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/06/30/tutorial-how-to-install-shiny-server-on-ubuntu-22-04/ -R shiny is a great tool for one to present research results in a dynamic and interactive way. Today, I’d introduce how to install R shiny server on Ubuntu 22.04. The content will include installation, configuration, and connecting to R shiny server. Installation Here I ... [Read more...]

[R] install and configure Rstudio-server in ubuntu

May 27, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/05/28/r-install-and-configure-rstudio-server-in-ubuntu/ -Rstudio server provides an integrative environment for a data scientist to do data analysis in R and python and allows one to login into it via a browser anywhere. Today, I will going to show how to install Rstudio server in Ubuntu under AWS. Setup EC2 ... [Read more...]

[R] Create ggplot histograms with y value being fractions

May 25, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/05/26/r-create-ggplot-histograms-with-y-value-being-fractions/ -
library(knitr)
opts_chunk$set(echo=T, warning=F, fig.width=7, fig.height=7, fig.path="static/")
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
ggplot2 has been a great tool for making plots. Today, I would like to talk about histogram. It is straight forward to make a histogram with geom_histogram(), but not so when one wants to use fractions instead of counts as values on ...
[Read more...]

[R] Need import S3 functions for a package to use

January 19, 2023 | Zhenguo Zhang

Zhenguo Zhang's Blog /2023/01/20/r-need-import-s3-functions-for-a-package-to-use/ -When developing an R package, it has been suggested to just put the dependent packages in Description file under Imports section. However, I recently found that for S3 methods exported by a package, one need to import such functions explicitly in order to use them ... [Read more...]

[R] Include external script or child documents in Rmarkdown

March 21, 2022 | Zhenguo Zhang

Zhenguo Zhang's Blog /2022/03/22/r-include-external-script-or-child-documents-in-rmarkdown/ -When one Rmarkdown document is too big, one can consider split the file into smaller ones. In this post, I will introduce the ways for this purpose. Include external R scripts There are two ways to include external scripts: using the functions source() or sys.source() ... [Read more...]

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)