git clone
git add *
git commit -m ".."
git push
x <- c(2,5,1,3)x[1] # the number 2x <- seq(1,5) # 1,2,3,4,5x <- 1:5 # 1,2,3,4,5x <- rep(2, 4) # 2,2,2,2length(c(1,2)) # 2x <- c(1,2) + c(1,2) # 2,4x <- c(1,2) + 3 # 4,5x <- c(1,1,1,1) + c(1,2) #2,3,2,3x <- c('one','two','three')
x[2] # 'two'x[c(1,2)] # 'one','two'
x[1:2] # 'one','two'x[c(TRUE, FALSE, TRUE)] # 'one','three'x <- c(1,2,3,4,5)
indices <- x > 3 # FALSE,FALSE,FALSE,TRUE,TRUE
x[indices]#3,4,5
x[x>3] #3,4,5
x <- c(2,5,1,3) # 2,5,1,3function_name <- function(arguments) {
statements
return(object)
}greet <- function(name) {
obj <- paste('Good morning', name, 'today is', date(), sep=" ")
return(obj)
}
greet("Mike") # Good morning Mike today is Thu Jan 14 15:24:26 2016if (SOME CONDITION IS TRUE) {
do something
}if (SOME CONDITION IS TRUE) {
do something
} else if (SOME OTHER CONDITION IS TRUE) {
do something else
} else {
do a default action
}if(condition1) {
statements
} else if (condition2) {
statements
} else {
statements
}# Boolean
if(TRUE) {
print("it's true!")
}
# Evaluated as a Boolean
if(x > 1) {
print("x is greater than one!")
}