-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAbsEEMSfilecomp_function.R
More file actions
55 lines (44 loc) · 1.94 KB
/
AbsEEMSfilecomp_function.R
File metadata and controls
55 lines (44 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# function for creating master file for corrected absorbance and fluorescence files
# For passing these files into a file that will calculate absorbance and fluorescence indicies
# 24 July 2015
# AJ PhD project
##################
abseemfilecomp <- function(directoryRaleigh, projectname, directorynoncorabs, filelist_EEMScor){
setwd(directoryRaleigh)
#create column with sample ID - extracted from corrected EEMS filename
y = length(filelist_EEMScor)
sample.ID <- 0 #create sample ID variable
for (i in 1:y){
sample.ID.temp <- strapplyc(filelist_EEMScor[i], paste("(.*)", "_", projectname, "_Raleighcorr.csv", sep = ""), simplify = TRUE)
sample.ID[i] <- sample.ID.temp
}
filelist <- cbind(filelist_EEMScor , sample.ID)
###########
#Abs - non-corrected
setwd(directorynoncorabs)
filelist_Abs_noncorr <- list.files(pattern = "ABS.dat$")
#create column with sample ID - extracted from ABS filename
y = length(filelist_Abs_noncorr)
for (i in 1:y){
sample.ID.temp <- strapplyc(filelist_Abs_noncorr[i], "001(.*)ABS", simplify = TRUE)
sample.ID[i] <- sample.ID.temp
}
filelist_Abs_noncorr <- cbind(filelist_Abs_noncorr, sample.ID)
############ create column with sample ID - extracted from corrected Abs filename
#Abs
setwd(directoryAbsEEMs)
filelist_Abscor <- list.files(pattern = "_AbsCorrected.csv$")
#create column with sample ID - extracted from ABS filename
y = length(filelist_Abscor)
for (i in 1:y){
sample.ID.temp <- strapplyc(filelist_Abscor[i], paste("(.*)","_", projectname,"_AbsCorrected",".csv", sep = ""), simplify = TRUE)
sample.ID[i] <- sample.ID.temp
}
filelist_Abs <- cbind(filelist_Abscor, sample.ID)
#######
# Merge EEM and Abs filenames by sample ID to create file with all of the filenames
data.1 <- merge(filelist, filelist_Abs, by = "sample.ID", all = TRUE)
data.1 <- merge(data.1, filelist_Abs_noncorr, by = "sample.ID", all = TRUE)
return(data.1)
}