Business Analytics Summary
Business Analytics Summary
### 3. Functions in R
- Functions allow repeated use of code with different inputs.
- Example: Function to calculate the area of a circle.
```r
areaofCircle <- function(R) {
Area <- 3.14 * (R^2)
return(Area)
}
print(areaofCircle(5)) # Output: 78.5
```
---
End of Summary for Session 3.
### 1. Vectors in R
- A vector is a group of data objects of the same type.
- Created using `c()` function:
```r
groupofInt <- c(1, 15, 11, -7)
```
- Mathematical operations apply element-wise:
```r
c(3,4,5) * 2 # Results: c(6, 8, 10)
```
### 3. Matrices in R
- A matrix is a 2D collection of data objects of the same type.
- Created using `matrix()` function:
```r
matrixM <- matrix(c(1,2,3,4,5,6), nrow=3, ncol=2)
```
---
End of Summary for Session 4.