

Use the plural if you’re adding more than one line of examples.


Now, we go to the R script and add some roxygen comments to the beginning. install.packages("roxygen2") library(roxygen2) The easiest way to create a help file is to use the roxygen2 package. I stored this function in a script called sortby.R. The first step is covered above with my sortby() function.

Some were incomplete or broken up into multiple pages. Now, there are a lot of tutorials out there on how to create R packages, but they all lacked something. The answer was to create my very own package. The problem I had then was how to find the function when I want to use it. Here’s the latest version of the function that I came up with: sortby <- function(df, col, desc = FALSE) Finally, I decided to create an easy-to-use function that could sort data frames for me. Every time I want to sort a data frame, I have to puzzle through how to do it, usually by looking up online how somebody else did it, then copying and modifying their code. I don’t know about you, but I find the method that R uses to sort data frames incredibly non-intuitive.
