Show Menu
Cheatography

R for Data Science Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Installing Packages

cat(".Rprofile: Setting UK repositoryn")
r = getOption("repos") # hard code the UK repo for CRAN
r["CRAN"] = "http://cran.uk.r-project.org"
options(repos = r)
rm(r)

install.packages("tree")

library(tree)
   

create­Dat­aPa­rtition

#It will distribute evenly the column Species
train.flag <- createDataPartition(y=iris$Species,p=0.5,list=FALSE)

iris[train.flag,]
iris[-train.flag,]

Counters

nrow(x)
ncol(x)