---
# System prepended metadata

title: Basic Kowledge
tags: [statistics, R, basic]

---

# Basic Kowledge


###### tags: `R` `statistics` `basic` 

 ## R: Basic Kowledge

**Comment**
Use # for comment
```r=
# This is a comment
```

**Assignments**
```r=
# Assign x = 5
x <- 5
# Check x = ?
x
# Assign the result of 3 + 4 to y
y <- 3 + 4
y
```

**Each statement end with semicolon (;) or new line** 
```r=
x = 2
y = 3
a = 5; b = 4

```

**Some math operations**
```r=
# addition, subtraction, division, multiplication and exponentiation
1+1
3-2
4*5
10/2
3^2

# exponents and logarithms
exp(5)
log(3)
exp(log(3))

# absolute value and square root 
abs(-8)
sqrt(9)  

```

**Combine values into a vector or list**
```r=
# c(): combine values into a vector or list
x <- c(1.58, -0.29, 0.59, -0.38, 0.72)
max(x)     
min(x) 
range(x)  
mean(x)  
length(x) 
 ```
**NA: not available, missing values** 
```r=
z <- c(1:3, NA) 
z 
# check which if there is any NA   
ind <- is.na(z) 
ind 
   ```  

**Character strings are entered double quotes** 
```r=
y <- c(“apple”, ”water”, ”coffee”)
y
```

**Binomial Coefficient** 
```r=
choose(5, 3) 
factorial(5)

factorial(5)/(factorial(3) * factorial(5-3))

```
<br/>
<br/>

