Re: [R] howto get the number of columns and column names of multiply data frames

2009-08-10 Thread Frank Schäffer
Thanks for your replies. Both, Don and Stevens solutions worked well.

Best regards

Frank

__
R-help@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.


[R] howto get the number of columns and column names of multiply data frames

2009-08-09 Thread Frank Schäffer
Hi,
I' ve read in several files with measurements into R data frames(works 
flawlessly). Each dataframe is named by the location of measurement and 
contains hundreds of rows and about 50 columns like this

dataframe1.
date measurment_1   mesurement_n
1
2
3
..
..
..
n

For further processing I need to check whether or not ncol and colnames are 
the same for all dataframes. 
Also I need to add a new column to each dataframe with contain the name of the 
dataframe, so that this column can be treated as factor in later processing 
(after merging some seleted dataframes to one)

I tried out 

for (i in 1:length(ls()){
print(ncol(ls()[i])
}

but this does not work because r returns a "character" for i and therefore 
"NULL" as result.
Reading the output of ls() into a list also does not work.

How can I accomplish this task??

Best regards and thanks

Frank

__
R-help@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.