diff --git a/SubstrateHistory.R b/SubstrateHistory.R index 5bad2f6..4f121f3 100644 --- a/SubstrateHistory.R +++ b/SubstrateHistory.R @@ -27,7 +27,7 @@ SubstrateHistory <- function(sampleid) { empty.names <- names(sample.history)[which(empty.cols)] # Remove the identified empty columns plus those columns deemed unwanted sample.history <- sample.history[, -c(which(empty.cols == TRUE), - which(names(sample.history) == "sampleid"), + #which(names(sample.history) == "sampleid"), which(names(sample.history) == "created"), which(names(sample.history) == "project"))] # Save the empty column names as attribute to sample.history dataframe diff --git a/hms2seconds.R b/hms2seconds.R new file mode 100644 index 0000000..d2cc663 --- /dev/null +++ b/hms2seconds.R @@ -0,0 +1,28 @@ +################################################## +################# hms2seconds #################### +################################################## +hms2seconds <- function(hms_vec) { + ## Description: + ## Converts an hh:mm:ss time into seconds. + ## Usage: + ## hms2seconds(hh:mm:ss) + ## Arguments: + ## hms_vec: a character vector + ## Value: + ## A numeric vector with the same number of elements + ## as the input vector + # + seconds <- rep(NA, length(hms_vec)) + for (i in 1:length(hms_vec)) { + hms_str <- strsplit(hms_vec[i], ":")[[1]] + # We assume hours:min:sec, anything else, throw an error + if (length(hms_str) != 3) { + error("Input must be formatted as hh:mm:ss") + } + seconds[i] <- + as.numeric(hms_str[1]) * 3600 + + as.numeric(hms_str[2]) * 60 + + as.numeric(hms_str[3]) + } + return(seconds) +} \ No newline at end of file