CAROLINA WITH SOLUTIONS
putting in a dataset - ✔✔data<-
c(81,85,93,93,99,76,75,84,78,84,81,82,89,81,96,82,74,70,84,86,80,70,131,75,88,102,115,89,82,79,106)
length(data) - ✔✔tells you how may entries are in your vector
sort(data) - ✔✔puts data smallest to largest
summary(data) - ✔✔returns the five number summary and the sample mean
mean(data)
sd(data)
sum(data) - ✔✔sample mean
sample standard deviation
adds all the elements of the vector
seq(1,100,1)
seq(2,100,2) - ✔✔tells r to create the sequence of numbers from 1 to 100 by 1 (1,2,3...)
1:100 does the same thing
(2,4,6...100)
data<-read.table(file.choose(),header=TRUE)
read.cvs - ✔✔calls this dataset into r and you can name it whatever you want
getwd() - ✔✔creates the current working directory and calls in your data too
dim(data) - ✔✔checks dimensions of data
data - ✔✔type the name of the data to see it
data[1:5] - ✔✔calls in the first five rows of the dataset if you are working with a large dataset
head(data) - ✔✔shows the first few rows
, data[,1:2] - ✔✔all rows for columns 1 and 2
data[1:5,1:2] - ✔✔first five rows and first two columns
str(data) - ✔✔structure of the object
View(data) - ✔✔(capital V) puts your data in a viewable popup window
data$shoes - ✔✔calls in the column called shoes
attach(data) - ✔✔attaches data so you can work with it and don't have to keep calling it in
(if you attach several datasets that have the same column names r will be confused so you have to
detach before attaching again)
data<-subset(data,Type=="WT") - ✔✔you can pick out certain rows/columns and you can enter more ==
and "" in order to be more specific
hist(data) - ✔✔give you a histogram
hist(data,breaks=c(60,70,80,90)) - ✔✔creates a sequence and breaks them
xlab="percents of ..." - ✔✔x axis name
ylab="Frequency" - ✔✔y axis name
main="..." - ✔✔title of the graph
boxplot(data) - ✔✔gives a box plot
boxplot(...~...) - ✔✔gives side by side boxplots
boxplot(Oil~Type,names=c("WIld Type","Mutated")) - ✔✔creates your own label for the boxplot
plot(X,Y) - ✔✔create a scatterplot
X1 <- c(8,5,14,13,29)
X2 <- c(13,8,6,18,4) - ✔✔X1 is first line with the numbers you want
X2...
dbinom(j,n,p) - ✔✔gives P(Y = j) discrete binomial probability
pbinom(J,n,p) - ✔✔gives P(<=J) = P(Y = 0) + P(Y = 1) + ... + P(Y = J) exp binomial prob