Skip to content

Instantly share code, notes, and snippets.

@prasoonsharma
Created November 26, 2010 03:43
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save prasoonsharma/716254 to your computer and use it in GitHub Desktop.
Save prasoonsharma/716254 to your computer and use it in GitHub Desktop.
Atomic data types in R
# 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