This will read in all the data files in a directory.  I am assuming that
your file names are the same as the column names you want.

# use file names as column headers
setwd(...where ever you want it....)
result <- list()
for (i in list.files()){
    result[[i]] <- scan(i, what=0)  # assume single column of numbers
}
max.length <- max(unlist(lapply(result, length)))  # get maximum length
# pad with NAs
newData <- lapply(result, function(x){length(x) <- max.length; x})
yourDF <- data.frame(newData)


On 7/29/06, Kartik Pappu <kartik.pappu@gmail.com> wrote:
>
> Hello All,
>
> I have a device that spews out experimental data as a series of text
> files each of which contains one column with several rows of numeric
> data.  My problem is that for each trial it gives me one text file
> (and I run between 30 to 50 trials at a time) and I would ideally like
> to merge all these text files into one large data frame with each
> column representing a single trial.  It is not a problem if NA
> characters are added to make all the columna of eaqual length.  Right
> now I am doing this by opening each file individually and cutting and
> pasting the data into an excel file.  How can I do this in R assuming
> all my text files are in one directory.
>
> Is it also possible to customize the column headers.  For example if I
> have 32 trials and 16 are experimental and 16 are control and I want
> to name the columns "Expt1", Expt2",... "Expt16"  and the control
> columns "Cntl1",...Cntl16".
>
> Kartik
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

