by Suf | May 29, 2022 | Programming, R, Tips
The pipe operator, %>%, is a special function available under the magrittr package that allows you to pass the result of one function/argument to the other one in sequence. To use the pipe operator, you need to install and load the magrittr package....
by Suf | May 28, 2022 | Programming, R, Tips
This tutorial will go through how to remove outliers from a boxplot using ggplot2 in R with the help of code examples. Table of contentsExampleRemove Outlier Using outlier.shape=NASummary Example In the following example, we are going to use the iris dataset to create...
by Suf | May 28, 2022 | Programming, R, Tips
The easiest way to place two plots side by side using ggplot2 is to install gridExtra and then use the grid.arrange() function. For example, install.packages(“gridExtra”) grid.arrange(plot1, plot2, ncol=2) This tutorial will go through how to place two...
by Suf | May 25, 2022 | Programming, R, Tips
You can rotate the axis labels by using angle parameter of the element_text() function when modifying the theme of your plot, for example: theme(axis.text.x = element_text(angle = 90, vjust = 0.5) We can use vjust and hjust in element_text() to add horizontal and...
by Suf | May 22, 2022 | Programming, R, Tips
This R tutorial will go through how to order bars in a ggplot2 bar chart with code examples. Table of contentsExampleSolution #1: Manually Order BarsSolution #2: Sort Bars in Descending OrderSolution #3: Sort Bars in Ascending OrderSummary Example Consider the...
by Suf | May 21, 2022 | Finance, Programming, R, Tips
R provides several powerful tools for financial market analysis. This tutorial will go through how to download and plot the daily stock prices from Yahoo! Finance using quantmod. Yahoo finance provides free access to historic stock prices at the time of writing this...