Statistical functions:
probability functions:
# mean ()
# sd()
# cor()
# summary()
# length() find out how many values are there
# str()
# edit() you can create a data frame and use this function to add data
# fix() you can edit your data frame
# rnorm()
X <- rnorm(5, mean = 20, sd = 3.5)
# round()
Y <- round(X, digits = 2)
print(Y)
## [1] 19.48 15.42 24.33 24.08 19.40
# table () pass in any two variables for rows and columns
# attach()
# dettach()
# with() good function to refer variables in different dataset
with(mtcars, {
print(summary(mpg))
plot(mpg, disp)
plot(mpg,wt)
})
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 10.40 15.43 19.20 20.09 22.80 33.90
# the limitation for with function is that variables created only exist in the brackets
# you can use special opprater <<- to have the variable exist outside of the brackets
# read.table('Studentgrades.cvs;, header= T, row.names ="studentID", sep = ")
# read.csv()
# help(read.table)
# length()
# dim()
# str()
# class()
# mode() determines how an object is stored
# names() give the names of components in an object
# c()
# cbind(object1, object2) combines two objectS as colomns
# rbind() combines two objects as rows
# object print an object
# head()
# tail()
# ls()
# rm()
# newobject () <- edit(object)
# fix()
# plot(x, y)
# plot(dose, drugA, type= "b") this means both lines and dots should be ploted.
# hist()
# boxplot()
# par() is used for specify graphic parameters, means values the same unless changed, for the entire dataset
# par(lty = 2, pach = 17) line type and solid triangle
# pch = symbols for plotting
# cex = sybol size, number of scaled, default = 1, 1.5 is 50% larger, 0.5 is 50% smaller,
# lty = specifies the line type
# lwd = line width 1 is default.
# rgb(1,1,1) create colors based on red-green-blue values.
# rainbow(), heat.colors(), terrain.color(), topo.colors(), and cm.colors()
# rainbow(10) give you 10 continuous rainbow colors
# abline(lm(mpg~wt))
# title("Regression of MPG on Weight")
# pdf("Title.pdf")
# blocks of codes
# dev.off()
# c() combine variables/objects
# detach() Detach data
# getwd() get working directory
# setwd() set working directory
# q() this ends the function and let you quit
# demo() enter this in the command line without any parameters
# data() shows you the dataset
# help.start() general help, will show you a windows in doc section
# help('foo') or ? foo shows you help on function foo (quotation marks are optional)
# help.search('foo') will search strings of "foo" in help system
# example() shows you an example of function
# RsiteSearch('Foo") this will search things on R site
# vigette() you need to have quotation marks for it to run
# ls() will list all the variables in your workspace
# rm() remove any variable you want
# :: used to specify what package and what variables/function that you want
# history()
# search() tell you which packages are installed and ready to use