Erin-Rooney/Y1_fairbanks

Diffractogram patterns file loading and large list to dataframes

Closed this issue · 0 comments

@kaizadp

For the fairbanks samples, I have more .xy (ASCII) files, so I'm trying to deal with them in better ways that I did with the Healy/Toolik samples. It's not going well, though. Should I give up and do the way I did it before?

I load everything into one big list. It doesn't keep the names. I find a way to bring it in with the names, it only imports six of the files and then it lumps two columns into one column. There are just a ton of problems.

#trying to bring all of the .xy ASCII files in
dataFiles <- lapply(Sys.glob("processed/*.xy"), read_xyData)
#now bringing them in as not Rxylib files, which are impossible to deal with
dataFiles2 <- lapply(Sys.glob("processed/*.xy"), read.delim)
#now trying to bring them in with names but only six are loading. Why? WHy???
#also, two columns are loading as one. Need to by separated by " "
filenames <- head(list.files("processed/", pattern = "*.xy", recursive = TRUE, full.names = TRUE))
filenames
tools::file_path_sans_ext(basename(filenames))
dataFiles2b <- setNames(lapply(filenames, readLines),
tools::file_path_sans_ext(basename(filenames)))
#now all loaded, not rxylib, no names, two columns lumped into one column
list_data <- Map(as.data.frame, dataFiles2)
#don't know why I did this. Just trying things.
write.csv(list_data, "processed/list_data.csv")