[Rmarkdown] Automate word document generation using Rmarkdown
I knew that Rmarkdown was very power to generate all kinds of document formats such as html, pdf, word, powerpoint, etc, but until recently, I have never used it to generate word documents (most time, I generated html and pdf files). When I started to generate word documents using Rmarkdown, I found that it was not so straightforward. The main issue is how to specify the different text styles to different texts, such as “Heading 1”, “Body Text”, etc.
2024-01-28   schedule 2 min 25 s  
[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 refer columns in ggplot2 Let’s start an example of making a scatter plot by using the dataset mtcars. head(mtcars) ## mpg cyl disp hp drat wt qsec vs am gear carb ## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 ## Mazda RX4 Wag 21.0 6 160 110 3.
2023-11-11   schedule 2 min 54 s  
[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 changes accordingly. knitr::opts_chunk$set(echo=T, fig.align = "center", fig.width = 6, fig.height = 5, dpi=150, warning=FALSE) library(knitr) library(ggplot2) Let’s start with an example of making a scatter plot with the dataset mtcars. library(ggplot2) plt<-ggplot(mtcars, aes(x=wt, y=mpg, color=factor(cyl))) + theme_bw() plt<-plt+geom_point() plt But what if we create a function to make the plot and accept different variables for the color aesthetics?
2023-10-23   schedule 1 min 35 s  
[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 boxplot. We will use the data set ToothGrowth coming with R. dat<-ToothGrowth dat$dose<-as.factor(dat$dose) # convert the dose to a factor plt<-ggplot(dat, aes(x=dose, y=len, fill=supp)) + theme_bw() plt<-plt + geom_boxplot() plt add points with geom_jitter() Now let’s add points over the boxplots with the function geom_jitter().
2023-08-26   schedule 1 min 49 s  
[Tip] Set up RSS feed in blogdown and add it to R-bloggers
Hugo website comes with a default RSS template, which controls the format of the RSS feed for all pages in a website. One can check the RSS output by typing the following URL in the web browser: https://my-website.com/index.xml The default output seems containing a full content for the ‘’ field, but when checking a section/sub-website, the content in ‘’ seems trucated. For example, checking the following URL: https://my-website.
2023-07-21   schedule 2 min 21 s  
[Tutorial] Github/gitlab ssh key setup
One can connect to gitlab or github via ssh and https. Today, I will explain how to generate ssh key, add it to the github/gitlab account, and connect to github/gitlab using ssh in Ubuntu. Since github and gitlab are similar, I will use github as example here: Generate ssh key 1 ssh-keygen -f ~/.ssh/id_rsa_github The above command will generate two files: id_rsa_github and id_rsa_github.pub. The latter is the public key and should be copied to the github account.
2023-07-01   schedule 59 s  
[Tutorial] How to create and tune ridgeline 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.
2023-07-01   schedule 1 min 21 s  
[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 install the compiled version by downloading from the R shiny server website. As of my writing, the Ubuntu version supports Ubuntu 18.04 and above. If no compiled version is available, one can compile it by following the instruction here.
2023-06-30   schedule 2 min 13 s  
[Linux] User management in Linux
Here is a summary of commands for user management in Linux. see all existing groups 1 getent group get all groups a user belongs to 1 groups username create a new group 1 sudo groupadd new_group add user to a group 1 2 3 sudo adduser username groupname # or sudo usermod -aG groupname username create a new user
2023-05-28   schedule 27 s  
[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 instance To access Rstudio server in an EC2 instance, one need to open correct port in the security group and set the Source to “Anywhere” (i.
2023-05-28   schedule 4 min 13 s