s-news
[Top] [All Lists]

Re: converting a file name to the name of a table

To: "carol white" <wht_crl@yahoo.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: converting a file name to the name of a table
From: "Jordan, Paul" <paul.jordan@roche.com>
Date: Mon, 21 May 2007 11:28:25 +0200
In-reply-to: <568064.59427.qm@web62008.mail.re1.yahoo.com>
References: <568064.59427.qm@web62008.mail.re1.yahoo.com>
Thread-index: AcebiliTPj5+pMQ4S8esdB0svsnEiA==
Thread-topic: converting a file name to the name of a table
Hi Carol,
try:
 
files <- list.files(".")
for (x in files)  eval(_expression_(x <- read.table(x)))
 
Good luck!
Paul


From: carol white [mailto:wht_crl@yahoo.com]
Sent: Wednesday, May 16, 2007 8:25 PM
To: s-news@lists.biostat.wustl.edu
Subject: converting a file name to the name of a table

Hi,
is there anyway to name a table that i create by read.table by the name of the file from which the content is read into the table?

I want to read the files in the current directory and into a table whose name is the name of the file. I tried as.name but doesn't work
 
files.lst = list.files(".")
 for (i in 1:length(files.lst))
+ as.name(files.lst[i]) =  read.table (files.lst[i], check.names = F, header = T)

thanks

carol


Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.

Upgrade Your Email - Click here!

<Prev in Thread] Current Thread [Next in Thread>