0

I'd like to the convert the values in the first column into row names.

There are some similar questions about it like this
Convert the values in a column into row names in an existing data frame in R

However, the thing is that I would like to do that in the files with listed up.
What should I do to apply into multiple files (ex. int_file[[i]])?

> exp = list.files(pattern=glob2rx("*_input_*.txt"))
> int_file = lapply(exp, read.table, sep="\t", header = T)

# I tried with int_files=lapply(exp, red.table. sep="\t", row.names=NULL)

> exp
[1] "1_input_1.txt" "2_input_2.txt"
> dim(int_file[[1])
[1] 2000 20
> dim(int_file[[2]])
[1] 3000 20

> type(int_file[[1]][1,1])
[1] "factor"
Community
  • 1
  • 1
user2913161
  • 1,115
  • 2
  • 13
  • 15
  • Is there a reason you want to do this in a single operation rather than with a loop? Not everything in `R` must be done without a loop. :) – dg99 Nov 22 '13 at 23:49
  • `row.names=1` perhaps? – Neal Fultz Nov 22 '13 at 23:51
  • Yes, I have bunch of files to do run with same code and get the result. Most codes should be ran through a loop like this.
    for ( i in 1:length(int_file){do stuff.. int_file[[i]]}
    – user2913161 Nov 22 '13 at 23:52
  • 1
    So then just follow the solution on the page you linked, but put it inside a loop. `for (f in exp) { df=read.table(f, sep="\t", header=T); rownames(df) = df[,someColumn]; ... }` – dg99 Nov 22 '13 at 23:59

0 Answers0