R Flashcards
mode()
Identifies the type of variable in the brackets
i.e. is is a character or numeric
What is a vector?
A list of numbers or letters or character strings
c()
combines the string of data into a vector.
vectorname[n]
gives the nth value in the named vector
vectorname[n1 : n2]
Gives the n1th to n2th values in the vector, inclusive.
vectorname[-n]
Gives the whole of the named vector, without the nth value.
sum()
Gives sum of vector
mean()
Gives mean of vector
max()
Gives largest value of vector
median()
Gives median of vector
var()
Gives variance of vector
sd()
Gives standard deviation of the vector
name = function(x) actualfunction(variable)
Defines the name as a function which is another function applied to a variable
sqrt()
Square roots value
mad()
Gives the median absolute deviation (comparable to the standard deviation)
shapiro.test()
Applies the shapiro test to the data, comparing it to a normal distribution.
Lower p value than 0.05 lets us reject the null hypothesis.
IQR()
Gives the interquartile range of the data
summary()
Gives the minimum, maximum, median and mean as well as the 1st and 3rd quartiles.
barplot()
Gives a bar graph of a vector.
table()
Gives a frequency table of a vector.
length()
Gives the length of a vector.
labels = as.vector(c(list of the names for the bars)
barplot((data in graph), names.arg = labels, xlab = name of x axis, ylab = name of y axis)
Labels the bars in the graph after the items in the labels vector.
hist()
Gives histogram.
hist(GC, breaks = 50)
Allows us to chose how many bars in our graph.