This is a follow up post from my previous post.
#after setting up the working directory that has multiple csv files (92 files), is all read into a single list but as different data frames. fnames <- list.files() #reading it into separate data frames within the list. Now the list will have 92 csv file as separate df. myfiles = lapply(fnames, read.delim)
Now that the list has all 92 csv files as separate data frame, we are extracting and keeping the columns we need. We need 2 columns named "name", and "fraction_total_reads".
lst1 <- lapply(myfiles, "[", c("name", "fraction_total_reads"))
Now each csv within the list has only 2 columns by "name" and "fraction_total_reads". But they all have different number of rows. Before I save these files...I want to rename the column
fraction_total_reads, in each csv file to their corresponding sample name.
For example: within lst1... df[] fraction_total_reads had to be renamed as
P_A_1. so on and so forth.
lst2 <- rename(lst1[[x]], c("fraction_total_reads" = "P_A_1", "fraction_total_reads" = "P_A_2"...so on till all 92 samples ar named)
Would a correct version of the above code work? The above didn't work.
Once I rename then columns in each data frame within the list, I want to merge them by the column name. Remember they have same number of columns, but different number of rows. Thank you for any help regarding this.