From fbd17fb8b9927a75b15a3f12d13e2121b649e0da Mon Sep 17 00:00:00 2001 From: sanjnac13 Date: Fri, 19 Nov 2021 09:55:48 -0500 Subject: [PATCH] Answer to Exercise 09 --- Exercise09Answer.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Exercise09Answer.R diff --git a/Exercise09Answer.R b/Exercise09Answer.R new file mode 100644 index 0000000..fc1da44 --- /dev/null +++ b/Exercise09Answer.R @@ -0,0 +1,31 @@ +#set working directory +setwd("C:Desktop/R Studio Projects/Biocomp_tutorial11") + +# define the function +cov_function <-function(dir,column_num,nrow=50){ + data <- list.files(dir) + cov <- 0 + + for(i in data){ + table <- read.table(file= i, header=TRUE, sep=",", stringsAsFactors=FALSE) + rows <- length(table[,col]) + if(rows