[R] combine many .csv files into a single file/data frame

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Oct 15 22:41:44 CEST 2004


On 15-Oct-04 bogdan romocea wrote:
> Dear R users,
> 
> I have a few hundred .csv files which I need to put
> together (full outer joins on a common variable) to do a
> factor analysis. Each file may contain anywhere from a few
> hundred to a few thousand rows. What would be the most
> efficient way to do this in R? Please include some sample
> code if applicable.

If you're using Linux/Unix, you should consider using the 'join'
command. Simple example (jpoining files "j1" and "j2"):

$ cat j1
1 a
1 b
2 c
2 d
2 e
3 f
3 g
4 h

$ cat j2
1 A
1 B
2 C
3 D
3 E
3 F

$ join j1 j2
1 a A
1 a B
1 b A
1 b B
2 c C
2 d C
2 e C
3 f D
3 f E
3 f F
3 g D
3 g E
3 g F

See 'man join' for details of options which you can use to
adapt the command to your needs.

Hoping this helps,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 15-Oct-04                                       Time: 21:41:44
------------------------------ XFMail ------------------------------




More information about the R-help mailing list