This class is supported by DataCamp, an intuitive learning platform for data science and analytics. Learn any time, anywhere and become an expert in R, Python, SQL, and more. DataCamp’s learn-by-doing methodology combines short expert videos and hands-on-the-keyboard exercises to help learners retain knowledge. DataCamp offers 325+ courses by expert instructors on topics such as importing data, data visualization, and machine learning. They’re constantly expanding their curriculum to keep up with the latest technology trends and to provide the best learning experience for all skill levels.

**Your First Datacamp Experience**

The left-hand panel is a "script" (like a text file on your computer). You can store your commands and make comments to structure the code. On the right-hand panel you see the R console. You may type one command at a time or run an entire script. Follow the instructions from the script and solve the exercise. Create a vector and display it's value via the print() function. Click submit. Done.

```
# This will get executed each time the exercise gets initialized
b = 6
```

```
# Create a variable a, equal to 5
# Print out a
```

```
# Create a variable a, equal to 5
a <- 5
# Print out a
print(a)
```

```
test_object("a")
test_function("print")
success_msg("Great job!")
```

`<-`

) to create the variable `a`

.**Your First Data Analysis Experience**

Create two vectors according to the following table. Run a linear regression and store the output in an object named "model". Create a scatter plot of y versus x and add the regression line to illustrate the relationship between the two.

Variable | |||||
---|---|---|---|---|---|

x | 4 | 13 | 19 | 25 | 29 |

y | 10 | 12 | 28 | 32 | 38 |

```
# This will get executed each time the exercise gets initialized
```

```
# Create two vectors x and y.
# Use lm() to create a linear model of y versus x and save the result to "model".
# Create a scatter plot of the relationship between y and x with plot().
# Add the regression line to the scatterplot to illustrate the relationship with abline().
```

```
# Create two vectors x and y.
x <- c(4,13,19,25,29)
y <- c(10,12,28,32,38)
# Use lm() to create a linear model of y versus x and save the result to "model".
model <- lm(y~x)
# Create a scatter plot of the relationship between y and x with plot().
plot(x,y)
# Add the regression line to the scatterplot to illustrate the relationship with abline().
abline(model)
```

```
test_object("x")
test_object("y")
test_object("model")
test_function("plot")
test_function("abline")
success_msg("Great job! Now, you are ready for data analysis of SOEP.")
```

`c()`

function to combine values into a vector. Use the `lm()`

function to create a linear model. For a scatterplot use `plot()`

, to add a straight line you need `abline()`

.