Professional Documents
Culture Documents
xvec
##When you make a mistkae in R, these error messages pop up
x.dumm<c(1,4,6,7)
max(x.vec)
length(x.vec)
max(x.dummy)
##You can write all sorts of formulas, naming things and creating
##Shortcuts for yourself
x.mean=sum(x.vec)/length(x.vec)
x.mean
##The above formula calculated the mean for the vector name x.vec
log(bieber)
##You can also create a code so that you don't have to fill manually##
jay.z<-matrix(nrow=2,ncol=3)
jay.z[is.na(jay.z)]=0
jay.z
grades<-read.table("grades.txt",header=TRUE)
grades
##If you just want to see the top part ot check the headings, just##
##ask to see the 'head'##
head(grades)
#If you attach your data, then R will recognize the headings##
##in your dataset###
attach(grades)
Final_Grade
##So now you can see only the final letter grades##
##If you don't attach, you need a different code##
grades$Final_Grade
##We can also add these alterations to the dataset right in R##
grades2<-cbind(grades,curved)
grades2
##As you can see it didn't eliminate the original percents, just##
##added the new column with the curved grades##
##We could write code to change the letter grades as well (but won't now##
area<-read.table("country.area.txt",header=TRUE)
area
head(area)
country<-read.table("country.area.txt",header=TRUE)
plot(country$Rank,country$Totalsq.km)
plot(country$Country,country$Total.sqkm)
plot(country$Rank,country$Total.sqkm)
##Now let's say that we can to give each country a different color##
##Or better yet, let's highlight certain countries so we can see them##
##Now let's change the colors from black to blue##
barplot(grades$Student,grades$Points,xlab="Student",ylab="Total Points")
attach(tomato.full)
head(tomato.full)
mean(treat.1)
median(treat.1)
mode(treat.1)
sd(treat.1)
var(treat.1)
boxplot(tomato.full)
boxplot(tomato.full,xlab="Treatment",ylab="Tomato Production(kg)",col="blue")
###To run the ANOVA, we need a table that just has the means of each group#####
###Let�s do that in Excel and read in the new file#####
###Let�s try doing pairwise comparisons#####
###First read in the data####
tomato4<-read.table("treat.4.txt",header=TRUE)
###Check it out######
tomato4
#####The code for ANOVA using the aov function######
aov.out=aov(treat.4~control,data=tomato4)
####Check out the summary#####
summary(aov.out)
####What is this saying?######