Skip to content

Instantly share code, notes, and snippets.

@bakerwm
Forked from prasoonsharma/gist:716254
Created June 3, 2014 16:56
Show Gist options
  • Save bakerwm/d5ebdee49bcc171bc5a9 to your computer and use it in GitHub Desktop.
Save bakerwm/d5ebdee49bcc171bc5a9 to your computer and use it in GitHub Desktop.
# ATOMIC DATA TYPES IN R
# Character
first.name <- "Kirk"
# Integer
age <- 25
# Numeric
hourly_wage <- 27.25
# Factor: Categorical variables (take on a limited number of different values). Similar to lookups in Excel/databases
office <- factor("NYO", levels = c("NYO", "MUM", "SYD"))
# Boolean
married <- TRUE
# OPERATIONS ON ATOMIC TYPES
# Character
last.name <- "Davis"
full.name <- paste(first.name, last.name)
# Integer
time.till.retirement <- 60 - age
# Numeric
weekly.compensation <- 40 * hourly_wage
round(hourly_wage, 1)
# absolute
abs(-39 + 10)
# Boolean
has.kids <- TRUE
# AND
married && has.kids
# OR
married || has.kids
# NOT
! married
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment