how to use melt function from data.table within a for loop

I'm looking for some help with the following.
The data are into two folders. Each file is a txt file containing 16 columns and more than 7000 rows like this:

head(a1)
v1 v2 ... v16
2.0742 1.1520 ... 5.6852
-1.4071 1.1848 ... 2.7629

I want to transform each file into a single long column, using the library data.table like this :

library(data.table)    
setDT(a1)
a1<-melt(a1)[, .(value)]
v1
2.0742
-1.4071
1.1520
1.1848
...
5.6852
2.7629

The idea is to build a for loop that loads each file, transforms it into a single column dataframe and then exports it into another folder.
Any idea from where to start?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.