I'm trying to clean a large amount of data, so I wrote a function to clean it. Additionally, I wrote some code that pasted together the prefix of the name of each data set (which is the same between data sets) and the suffix, which is different. It put these names into a list. I then wrote a function to import all of my data and clean it. The importation worked, but the cleaning does not since my cleaning function needs a data frame, but it recognizes the names in my list as a character.
clean= function(x){
x=x[-c(1:2,1604:1658),]
colnames(x)= c("Wavelength","Reflection")
return(x)
}
files_suffixes=c()
for(a in 1:78){
if (0<a && a<4){
files_suffixes[a]=paste0("6.0",a,"-s00-m01-1")
}
if (3<a && a<7){
files_suffixes[a]=paste0("6.0",a-3,"-s00-m01-2")
}
if (6<a && a<10){
files_suffixes[a]=paste0("7.0",a-6,"-s00-m01-1")
}
if (9<a && a<13){
files_suffixes[a]=paste0("7.0",a-9,"-s00-m01-2")
}
if (12<a && a<16){
files_suffixes[a]=paste0("8.0",a-12,"-s00-m01-1")
}
if (15<a && a<19){
files_suffixes[a]=paste0("8.0",a-15,"-s00-m01-2")
}
if (18<a && a<22){
files_suffixes[a]=paste0("9.0",a-18,"-s00-m01-1")
}
if (21<a && a<25){
files_suffixes[a]=paste0("9.0",a-21,"-s00-m01-2")
}
}
for(x in 1:length(files_suffixes)){
assign(paste0("sa1976",files_suffixes[x]),read.csv(paste0("V:/vuv-data/proj/Cary-Film-Comparision/Cary/Reflection/sa1976",files_suffixes[x],".csv"), header=FALSE))
assign(paste0("sa1976",files_suffixes[x]),clean(paste0("sa1976",files_suffixes[x])))
}
I don't fully understand why it worked to import the files, but it wont work for the function, but regardless, is there a way to match up the names in my list to the data frames they represent?