# Seminar 1, group 4
# defining values
x <- 3 + sin(pi/2)
sqrt(x)
x <- sqrt(x)
w <- "2"
v <- "word of the day"
w <- as.numeric(w)
# also see as.character as.integer
# sequences
g <- seq(1,10)
h <- 1:10
for(i in 1:10) {
print(i)
}
# vectors
a <- c(12,1,2,3)
a[3]
sort(a)
b <- sort(a)
b[3]
typeof(a)
length(a)
n <- length(a)
for(i in 1:n){
print(a[i])
}
## Working with packages
# install.packages("tidyverse")
library(tidyverse)
car_frame <- mpg
ggplot(data = car_frame) +
geom_point(mapping = aes(x=displ,y=hwy))
ggplot(data = car_frame) +
geom_point(mapping = aes(x=displ,y=hwy, color=class))
ggplot(data = car_frame) +
geom_point(mapping = aes(x=displ,y=hwy)) +
geom_smooth(mapping = aes(x=displ,y=hwy))
ggplot(data = car_frame, mapping = aes(x=displ,y=hwy)) +
geom_point() +
geom_smooth()Group 1: Seminar 1
Here is the material from today’s seminar.
R Script
R Markdown
Link to published published markdown: html.
---
title: "Seminar 1, Group 4"
output: html_document
---
## Markup
make a list
- item 1
- item 2
- sub-item 2.1
numbered list
1. number 1
2. number 2
Add math
$$
Y = X\beta + u
$$
in line $\beta$.
## Adding code
Code block
```{r}
library(tidyverse)
car_frame <- mpg
ggplot(data = car_frame) +
geom_point(mapping = aes(x=displ,y=hwy, color=class))
```