diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/Biocomp_tutorial9.Rproj b/Biocomp_tutorial9.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/Biocomp_tutorial9.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/Exercise_9_answers.R b/Exercise_9_answers.R new file mode 100644 index 0000000..b5931be --- /dev/null +++ b/Exercise_9_answers.R @@ -0,0 +1,41 @@ +###Script answer to question 1 + +##replace wages.csv with wanted table +#x will be number of lines that we want to head + +y<- read.table("wages.csv", sep = ",", header = TRUE, stringsAsFactors = FALSE) +z <-y[c(1:x),] +z + +###Number 2 answers +##Loading iris file +#a) +Irisdata<- read.csv("iris.csv", sep = ",", header = TRUE, stringsAsFactors = FALSE) +numcol<-length(Irisdata[1,]) +b<-numcol - 1 +numrow<- length(Irisdata[,1]) +c<-numrow - 1 +Ismall<-Irisdata[c(c:numrow),c(b:numcol)] +Ismall +#b) +Sotosa<-Irisdata[Irisdata$Species=="setosa",] +nrow(Sotosa) +versicolor<-Irisdata[Irisdata$Species=="versicolor",] +nrow(versicolor) +virginica<-Irisdata[Irisdata$Species=="virginica",] +nrow(virginica) + +#c) + +Irisdata[Irisdata$Sepal.Width>3.5,] + +#d) + +write.csv(Sotosa, file = "setosa.csv") +read.csv("setosa.csv",sep = ",", stringsAsFactors = FALSE) + +#e) + +min(virginica$Petal.Length) +max(virginica$Petal.Length) +mean(virginica$Petal.Length) diff --git a/setosa.csv b/setosa.csv new file mode 100644 index 0000000..1f67a2f --- /dev/null +++ b/setosa.csv @@ -0,0 +1,51 @@ +"","Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","Species" +"1",5.1,3.5,1.4,0.2,"setosa" +"2",4.9,3,1.4,0.2,"setosa" +"3",4.7,3.2,1.3,0.2,"setosa" +"4",4.6,3.1,1.5,0.2,"setosa" +"5",5,3.6,1.4,0.2,"setosa" +"6",5.4,3.9,1.7,0.4,"setosa" +"7",4.6,3.4,1.4,0.3,"setosa" +"8",5,3.4,1.5,0.2,"setosa" +"9",4.4,2.9,1.4,0.2,"setosa" +"10",4.9,3.1,1.5,0.1,"setosa" +"11",5.4,3.7,1.5,0.2,"setosa" +"12",4.8,3.4,1.6,0.2,"setosa" +"13",4.8,3,1.4,0.1,"setosa" +"14",4.3,3,1.1,0.1,"setosa" +"15",5.8,4,1.2,0.2,"setosa" +"16",5.7,4.4,1.5,0.4,"setosa" +"17",5.4,3.9,1.3,0.4,"setosa" +"18",5.1,3.5,1.4,0.3,"setosa" +"19",5.7,3.8,1.7,0.3,"setosa" +"20",5.1,3.8,1.5,0.3,"setosa" +"21",5.4,3.4,1.7,0.2,"setosa" +"22",5.1,3.7,1.5,0.4,"setosa" +"23",4.6,3.6,1,0.2,"setosa" +"24",5.1,3.3,1.7,0.5,"setosa" +"25",4.8,3.4,1.9,0.2,"setosa" +"26",5,3,1.6,0.2,"setosa" +"27",5,3.4,1.6,0.4,"setosa" +"28",5.2,3.5,1.5,0.2,"setosa" +"29",5.2,3.4,1.4,0.2,"setosa" +"30",4.7,3.2,1.6,0.2,"setosa" +"31",4.8,3.1,1.6,0.2,"setosa" +"32",5.4,3.4,1.5,0.4,"setosa" +"33",5.2,4.1,1.5,0.1,"setosa" +"34",5.5,4.2,1.4,0.2,"setosa" +"35",4.9,3.1,1.5,0.2,"setosa" +"36",5,3.2,1.2,0.2,"setosa" +"37",5.5,3.5,1.3,0.2,"setosa" +"38",4.9,3.6,1.4,0.1,"setosa" +"39",4.4,3,1.3,0.2,"setosa" +"40",5.1,3.4,1.5,0.2,"setosa" +"41",5,3.5,1.3,0.3,"setosa" +"42",4.5,2.3,1.3,0.3,"setosa" +"43",4.4,3.2,1.3,0.2,"setosa" +"44",5,3.5,1.6,0.6,"setosa" +"45",5.1,3.8,1.9,0.4,"setosa" +"46",4.8,3,1.4,0.3,"setosa" +"47",5.1,3.8,1.6,0.2,"setosa" +"48",4.6,3.2,1.4,0.2,"setosa" +"49",5.3,3.7,1.5,0.2,"setosa" +"50",5,3.3,1.4,0.2,"setosa"