From ab3a4a91d4d760dedfe48c4cd6624b251c9c6579 Mon Sep 17 00:00:00 2001 From: Erin Maron Date: Wed, 17 Nov 2021 17:28:11 -0500 Subject: [PATCH 1/4] first round --- MaronTutorial11.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 MaronTutorial11.R diff --git a/MaronTutorial11.R b/MaronTutorial11.R new file mode 100644 index 0000000..9b7aeb7 --- /dev/null +++ b/MaronTutorial11.R @@ -0,0 +1,12 @@ +#Tutorial Assignment 12 +setwd("/Users/erinmaron/Desktop/r-novice-inflammation/BioComp/ClassWork/Biocomp_tutorial11") +dir<-function(directory, x){ + data<-read.table("*.csv") + stdev<-stdev(data$x) + output(for(i in stdev)) + if (nrow(file)<50){ + print("warning: low level of data") + } else if (nrow(file)>50){ + print("warning: entry does not have 50 entries") + } +} \ No newline at end of file From 7b66317d5ddd449a40fd9355c0a73bcfe9add7b9 Mon Sep 17 00:00:00 2001 From: Erin Maron Date: Wed, 17 Nov 2021 19:14:56 -0500 Subject: [PATCH 2/4] second --- MaronTutorial11.R | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 MaronTutorial11.R diff --git a/MaronTutorial11.R b/MaronTutorial11.R deleted file mode 100644 index 9b7aeb7..0000000 --- a/MaronTutorial11.R +++ /dev/null @@ -1,12 +0,0 @@ -#Tutorial Assignment 12 -setwd("/Users/erinmaron/Desktop/r-novice-inflammation/BioComp/ClassWork/Biocomp_tutorial11") -dir<-function(directory, x){ - data<-read.table("*.csv") - stdev<-stdev(data$x) - output(for(i in stdev)) - if (nrow(file)<50){ - print("warning: low level of data") - } else if (nrow(file)>50){ - print("warning: entry does not have 50 entries") - } -} \ No newline at end of file From 3043b964cb8c78b587602d1fa1290bb655d2374d Mon Sep 17 00:00:00 2001 From: Erin Maron Date: Wed, 17 Nov 2021 19:18:41 -0500 Subject: [PATCH 3/4] trying again --- MaronTutorial11.R | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 MaronTutorial11.R diff --git a/MaronTutorial11.R b/MaronTutorial11.R new file mode 100644 index 0000000..93d0e0d --- /dev/null +++ b/MaronTutorial11.R @@ -0,0 +1,18 @@ +#Tutorial Assignment 12 +setwd("/Users/erinmaron/Desktop/r-novice-inflammation/BioComp/ClassWork/Biocomp_tutorial11") + +#Actual Function +dir<-function(x,y){ + input<-list.files(x, pattern="*.csv",full.names = TRUE) + data<-lapply(input,read.csv) + stdev<-sd(data$y) + mean<-mean(data$y) + print((stdev/mean)*100) + if (nrow(file)<50){ + print("warning: low level of data") + }else if (nrow(file)>50){ + print("warning: entry does not have 50 entries") + } +} + + From 738ad5a6bc63025907f44f941662192d9d844bd7 Mon Sep 17 00:00:00 2001 From: Erin Maron Date: Thu, 18 Nov 2021 20:39:39 -0500 Subject: [PATCH 4/4] Final Version Maron --- MaronTutorial11.R | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/MaronTutorial11.R b/MaronTutorial11.R index 93d0e0d..cd58e3c 100644 --- a/MaronTutorial11.R +++ b/MaronTutorial11.R @@ -1,18 +1,19 @@ #Tutorial Assignment 12 setwd("/Users/erinmaron/Desktop/r-novice-inflammation/BioComp/ClassWork/Biocomp_tutorial11") -#Actual Function -dir<-function(x,y){ - input<-list.files(x, pattern="*.csv",full.names = TRUE) - data<-lapply(input,read.csv) - stdev<-sd(data$y) - mean<-mean(data$y) - print((stdev/mean)*100) - if (nrow(file)<50){ - print("warning: low level of data") - }else if (nrow(file)>50){ - print("warning: entry does not have 50 entries") - } +#Calling Directory +dir<-function(directory,column){ + files<-list.files(pattern="*.csv") #pulls list of files from directory + for(i in 1:length(files)){ + data<-read.table(files[i]) #read files within directory + stdev<-sd(data$column==column, na.rm=FALSE) #find and set the standard deviation of data + mean<-mean(data$column==column) #repeat with the mean + } + if(nrow(files>=50)){ + return((stdev/mean)*100) #if the data has 50 or more points, print an error + }else{ + print("Warning:Less than 50 data point", cdev) #if there is insufficient data, print an error but continue to prvide output + } } - +#Keep getting error with calling a column name in arguement, but cannot seem to find what to fix after looking at notes and googling, so this is as far as I could get