I have 90 .csv files in my working directory and each of them is a 90*90 matrix. The files don't have consistent names (here is a sample)
>list.files()
[1] "sub-001-SGU-cn.csv"
[2] "sub-001-SGU-nv.csv"
[3] "sub-002-Cam-cn.csv"
[4] "sub-002-Man-lv.csv"
[5] "sub-002-SGU-cn.csv"
Each matrix is asymmetric (i.e., only upper triangle contains values and lower triangle contains zeros). I want to write a loop function to read each file in, conduct a log10 transformation of the upper triangle, and save the output in my working directory with the same name but adding in the suffix "_log.csv". How can I do this in R?
We may read the
.csvfiles in to alistwithread.csv, transform the data within thelist, and then write it back to the same directory after appending_logOr using
tidyverse