[R] Assign Names of columns in data.frame dinamically

From: Marcos Amaris Gonzalez <piratamarck_at_gmail.com>
Date: Thu, 31 Mar 2011 00:24:42 -0500

Hello List.

I have many files of ECG, each one with 7 column and I need only the second column and the name of each ECG. I am doing this but althought I have various days trying this i haven't gotten, so I ask help with this, if somebody cans help me I'll be so thankfully.


# loadEcgFiles <- function(Dir=".") {

        Dir <- ".";

        txtfiles <- list.files(paste(Dir),'.txt$');
        ecg = data.frame(ncol=1);
        len = length(txtfiles);

        for (i in 1:5 ) {

# i <- 1;
filename = paste(projectDir, "/" , txtfiles[i],sep=''); sample = read.table(filename, nrow=75000); sampleName = filename; sampleName=gsub("./", "",sampleName); sampleName=gsub(".txt", "", sampleName); temp <- sample$V2; names(temp) <- sampleName; ecg = cbind(ecg, temp);
# }

Thanks and sorry for my english.

Marcos Amaris González - Linux Counter #462840
No al SPAM!
"No es más rico el que más tiene, sino el que menos necesita."

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 31 Mar 2011 - 06:10:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Apr 2011 - 08:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive