Posts

Showing posts from July, 2017

Writing functions - Part one

Writing functions - Part one Writing functions - Part one CillianMacAodh 27 July 2017 Writing functions This post outlines the writing of a basic function. Writing functions in R (R Core Team, 2017) is fairly simple, and the usefulness of function writing cannot be conveyed in a single post. I have included “Part one” in the title, and I will add follow-up posts in time. The basic code to write a function looks like this: function_name <- function(){} The code for the task you want your function to perform goes inside the curly brackets {} , and the object you wish the function to work on goes inside the parenthesis () . The problem I have often found myself using a number of different functions together for multiple variables. For each variable, I need re-type each function. For example, when looking at a variable, I would often run the functions mean() , sd() , min() , max() , and length() together. Each