hello woRld

Prerequisites

Introduction to R & RStudio

Object assignment operator

birth_year <- 1950

Windows Mac
Shortcut Alt + - Option + -

R is case-sensitive

my_age <- 2020 - birth_year

My_age
Error in eval(expr, envir, enclos): object 'My_age' not found

If something comes in quotes, it is not defined in R.

ages <- c(25, my_age, 32)

names <- c("Menglin", "Mine", "Rafael")

data.frame(age = ages, name = names)
  age    name
1  25 Menglin
2  70    Mine
3  32  Rafael

Vocabulary

do(something)

do() is a function;
something is the argument of the function.

do(something, colorful)

do() is a function;
something is the first argument of the function;
colorful is the second argument of the function.

Getting Help

In order to get any help we can use ? followed by function (or object) name.

?c

tidyverse_style_guide

canyoureadthissentence?

tidyverse_style_guide

age <- c(6, 9, 15)

data.frame(age_kid = age)

After function names do not leave any spaces.

Before and after operators (e.g. <-, =) leave spaces.

Put a space after a comma, not before.

Object names are all lower case, with words separated by an underscore.