---
title: "R Notebook"
output: html_notebook
---
## rbind
```{r}
x <- data.frame("Subtype"=c("A","A","B","C"),"Gender"=c("m","f","f","m"),"Expression"=c(-0.54,-0.80,-1.03,-0.41))
x
x2 <- data.frame("Subtype"=c("D","D","D","D","D","B","A"),"Gender"=c("m","f","f","m","m","m","f"),"Expression"=c(3.22,1.02,0.21,-0.04,2.11,-1.21,-0.20))
x2
x3 <- rbind(x,x2)
x3
```
## cbind
```{r}
x <- data.frame("Subtype"=c("A","A","B","C"),"Gender"=c("m","f","f","m"),"Expression"=c(-0.54,-0.80,-1.03,-0.41))
x
x2 <- data.frame("Age"=c(32,21,34,67),"City"=c("New York","Houston","Seattle","Houston"))
x2
x3 <- cbind(x,x2)
x3
```
## merge
```{r}
df1 <- data.frame(CustomerId = c(1:6), Product = c(rep("Toaster", 3), rep("Radio", 3)))
df1
df2 <- data.frame(CustomerId = c(2, 4, 6, 7), State = c(rep("Alabama", 2), rep("Ohio", 2)))
df2
ij <- merge(df1, df2) # R autimatically joins fromes by common variable names: same as merge(df1, df2, by = "CustomerId")
ij
oj <- merge(x = df1, y = df2, by = "CustomerId", all = TRUE)
oj
loj <- merge(x = df1, y = df2, by = "CustomerId", all.x = TRUE)
loj
roj <- merge(x = df1, y = df2, by = "CustomerId", all.y = TRUE)
roj
```