Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.

Wednesday, January 15, 2014

Syntax for a User-Defined R Function

R functions are incredibly handy ways to have R carry out repetitive tasks for you without having to copy and paste lines in your code over and over again.  Since I don't daily write new R functions, I sometimes forget what the syntax is to create these custom functions.  Here's an example function I made to tell if a number is even or odd:


To run a custom R function simply use the function name with all the needed input variable in parenthesis (ex: even_num(413)).

No comments:

Post a Comment