[R] Adding more files to list

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Apr 25 16:30:24 CEST 2012


As to combining, use c().

as to tracking, keep track of the directory that goes with the file. There are various ways to do this:

a) keep a vector of filenames, and every time you combine vectors of filenames, do the same for the vectors of directory names. You will probably need to use rep() to turn one directory name into a vector of repeated values.

b) an organized way to accomplish option a above is to keep the vectors in data frames, and use rbind() instead of c() to combine them.

c) you will have to use paste() to combine the paths and filenames before you open them, so you might want to do so early on and keep track of which category each falls into using more presentable category names in the auxiliary vector(s) instead of tracking paths separately.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Brian Flatley <b.flatley at pgr.reading.ac.uk> wrote:

>Hi,
>
> 
>
>I have searched over the last two days to try and sort this problem but
>unfortunately I cannot find the correct solution.
>
>I have a main directory  - "Spectra"
>
>In this folder I have two subfolders "Normal"  and "Case"
>
> 
>
>I am using a package MALDIquant for processing of mass spectrometry
>data, 
>
>The following command will open and list all my files from the Normal
>subfolder (70 files containing spectrums)
>
> 
>
>Spectra <- mqReadBrukerFlex(file.path("Spectra/", "Normal"));
>
> 
>
>How do I add the "Case" folder to the list (another 70 spectra), so
>that I
>can then process all the files in the same manner and yet maintain
>their
>origin so when I want to do stats analyse on them I can differentiate??
>
> 
>
>Any help would be great, I am very much a beginner,
>
> 
>
>Brian 
>
> 
>
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list