> For the complete documentation index, see [llms.txt](https://docs.abi.am/abi-omicss-guide-2021/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abi.am/abi-omicss-guide-2021/week-2/r-programming/functions.md).

# Functions

Functions play a critical role in any R program and you tend to write a lot of them while programming. This section focuses on functions in R.

## Functions in R

To start, watch the following videos outlining the concept of functions in R:

1. [Your First R Function](https://www.coursera.org/learn/r-programming/lecture/BM3dR/your-first-r-function)
2. [Functions (part 1)](https://www.coursera.org/learn/r-programming/lecture/LP1kF/functions-part-1)
3. [Functions (part 2)](https://www.coursera.org/learn/r-programming/lecture/2xbdl/functions-part-2)

## swirl Exercises

Complete **swirl Lesson 9: Functions**, to solidify what you just learned, and return here afterward.

## Congratulations!

If you made it here, then congratulations! You have successfully completed this section. Move to the next portion of the guide with the arrow buttons below.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.abi.am/abi-omicss-guide-2021/week-2/r-programming/functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
