R Programming Cheat Sheet: by Via
R Programming Cheat Sheet: by Via
getwd() Find the working dir. c("String1","String2") Create a string vector c(2, 4, 6) Numeric vector
setwd("C:/file/path") Set the working dir. toString(x) Convert to string c("one","two","thr") Character vector
ls() List variables noqutoe(string) Print string w/o quote c(TRUE,FALSE) Logical vector
rm(object) Delete object sprintf() Print text & var values rep(1:2,times=3) Repeat a vector
str(object) Displays internal cat() Concatenate & print rep(1:2,each=3) Repeat the elements
structure of R object
toupper(string) Convert to uppercase which.min() which.max()
help.start() Launch help console Index of the min Index of the max
tolower(string) Convert to lowercase
install.packages("pac Install package
substr(string,n,m) Extract substrings in a
kage_name") Data Frames
string from n to m
library(package_nam Load package strsplit(string," ") Split elements of string data.frame(x=1:2, Create data frame
e) y=c('a', 'b'))
paste(c("a","b"),"c") paste0(c("a","b"),"c")
detach(package:pack Remove package Concatenate vectors Concat w/o separator View(df_name) See full dataframe
age_name)
head(df_name) See first 6 rows
scan() Read data values Probability Distributions tail(df_name) See last 6 rows