# Workflow Basics

## Coding Basics

# you can use R for calculations
1/200*30
[1] 0.15
(59+73+2)/3
[1] 44.66667
sin(pi/2)
[1] 1
# You can create new objects with the <-
# format: object <- value
# Reads as object name gets value
# you can use ALT and minus(-) to create tehe <-
x<- 3*4
y <- 4*5
x
[1] 12
y
[1] 20

## What’s in a Name

It can contain numbers, letters, _, and .

this_is_really_a_long_name <- 2.5
this

## Calling Functions

R functions are called like this:
function_name(arg1 = val1, arg2=val2, …)

seq(1,10)
 [1]  1  2  3  4  5  6  7  8  9 10

Quotation marks comes in pairs. If you forget the closing mark, R will tell you with [+]

y <- seq(1,10, length.out = 5)
y
[1]  1.00  3.25  5.50  7.75 10.00

## Exercises

1. Why does this code not work ?
my_variable <- 10 my-varIable # Error in eval(expr, envir, enclose): #> object “my varIable’ not found)

2. Tweak each of the following R commands so that they run correctly:

library(tidyverse)
ggplot(dota=mpg)+
geom_point(mapping = aes(x=displ, y=hwy))
Error in structure(list(data = data, layers = list(), scales = scales_list(),  :
argument "data" is missing, with no default
library(tidyverse)
ggplot(data=filter(mpg, cyl==8))+
geom_point(mapping = aes(x=displ, y=hwy))

1. Press Alt-Shift-k. What happens? How can you get to the same place using the menus?

Answer: Pops up the keyboard shortcut help!