class: center, middle, inverse, title-slide # STA 326 2.0 Programming and Data Analysis with R ## 🚦Built-in functions in R: Anatomy ### ### Dr Thiyanga Talagala --- <style type="text/css"> .remark-slide-content { font-size: 35px; } </style> ## Function Anatomy .pull-left[ ```r vec1 <- c(1, 2, 3, 4, 5) mean(vec1) ``` ``` [1] 3 ``` ```r vec2 <- c(1, 2, NA, 3, 4, 5) mean(vec2) ``` ``` [1] NA ``` ] ## Help `?mean` --- ## help: `mean` ![](mean.png) --- ## help: `sort` ![](sort.png) --- ![](functionanatomy.PNG) --- ## `mean` with additional inputs .pull-left[ ```r vec1 <- c(1, 2, 3, 4, 5) mean(vec1) ``` ``` [1] 3 ``` ```r vec2 <- c(1, 2, NA, 3, 4, 5) mean(vec2) ``` ``` [1] NA ``` ] .pull-right[ ```r mean(vec2, na.rm=TRUE) ``` ``` [1] 3 ``` ![](functionanatomy.png) ] --- ![](default.PNG) --- ![](sort.png) --- .pull-left[ ```r vec <- c(10, 1, 2, 4, 100, 15) sort(vec) ``` ``` [1] 1 2 4 10 15 100 ``` ```r sort(vec, decreasing = TRUE) ``` ``` [1] 100 15 10 4 2 1 ``` ```r sort(vec, decreasing = FALSE) ``` ``` [1] 1 2 4 10 15 100 ``` ] .pull-right[ ![](default.PNG) ] --- ## `rep` ![](rep.png) --- class: inverse, center, middle # [Vector creation with `rep` function in R!](https://hellor.netlify.app/2021/week1/l12021.html#64) --- class: center, middle ## Thank you! Slides available at: hellor.netlify.app All rights reserved by [Thiyanga S. Talagala](https://thiyanga.netlify.app/)