Skip to content

Instantly share code, notes, and snippets.

@korakot
Created June 22, 2016 04:41
Show Gist options
  • Save korakot/2b681871bdd7059249686ab8342e100a to your computer and use it in GitHub Desktop.
Save korakot/2b681871bdd7059249686ab8342e100a to your computer and use it in GitHub Desktop.
Vector in R #R
remain <- c(11,12,11,13)
# name the elements
suits <- c("spades", "hearts", "diamonds", "clubs")
names(remain) <- suits
# shortcut
remain <- c(spades=11, hearts=12, diamonds=11, clubs=13)
str(remain) # see detail
# a normal var is a vector of length 1
apples = 5
is.vector(apples) # TRUE
length(apples) # 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment