Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
setwd("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11")
x = '/hi/cd'
is.character(x)
if(TRUE && TRUE){print('jho')}
x = FALSE
is.boolean(x)
booltype(x)
logical(x)
is.logical(x)
x = ','
is.character(x)
raw <- read.table(file = 'wages.csv',header = FALSE,sep = ',')
View(raw)
View(raw)
raw <- read.table(file = 'wages.csv',header = TRUE,sep = ',')
View(raw)
View(raw)
data <- raw[,3]
data2 <- raw[,5]
length(data)
nrow(data)
nrow(raw)
ncol(raw)
nav <- is.na(data)
sum(checkNA)
sum(nav)
sum(!is.numeric(data))
sum(is.numeric(data))
is.numeric(data)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
data <- read.csv('wages.csv')
data <- data[,3]
sd(data)/mean(data)
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 10)
source("~/My Files/Notes/NDU/Coursework/Biocomputing/Biocomp_tutorial11/function.R")
myfunction(dir = 'wages.csv',sep = ',', col = 3)
myfunction(dir = 'wages.csv',sep = ',', col = 3)
myfunction(dir = 'wages.csv',sep = ',', col = 3)
myfunction(dir = 'wages.csv',sep = ',', col = 3,smallDataOverride = TRUE)
52 changes: 52 additions & 0 deletions function.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
myfunction <- function(dir,sep=',',col=1,smallDataOverride=FALSE){
#This function takes in four arguments:
# dir: directory to the file that is to be imported, in char
# sep: separation character
# col: specific column number to consider. Defaults to 1
# smallDataOverride: lets the function continue even with less than 50 points, defaults to FALSE


#Perform input argument check
#============================
if(!is.character(dir) | !is.character(sep) | !is.logical(smallDataOverride) | !is.numeric(col)){
print('One or more input values are of wrong data type')
return()
}


#import data and take the relevant column. Check if the num of column is correct
#============================
raw <- read.table(file = dir, header = TRUE, sep = sep)
if (ncol(raw) < col | col <= 0){
print('ERROR: Invalid column number')
return()
}
data <- raw[,col]


#Check the data size, and override if given the option
#============================
if (length(data) <= 50 & !smallDataOverride){
print('ERROR: Data size under 50. Override this with smallDataOverride argument')
return()
}else if (length(data) <= 50 & smallDataOverride){
print('WARNING: The data set is small. Results might not be accurate')
}


#check if the data includes NA values or non numeric values
#============================
if(sum(is.na(data)) != 0){
print('ERROR: Data includes NA values')
return()
}
if(sum(!is.numeric(data)) != 0){
print('ERROR: Data includes non numeric values')
return()
}


#Calculate and return
#============================
return(sd(data) / mean(data))
}
Loading