[R] Assigning Data a name from within another variable?

Kenny Larsen k.larsen at sheffield.ac.uk
Tue Jun 16 15:23:04 CEST 2009


Thnaks to both of you, with a combined effort of the Wiki and your code I
have now managed to get teh result I was after. 

When I have a better understanding of what the code is doing I shall make an
effort to contribut to the Wiki!

Cheers,

Kenny

Kenny Larsen wrote:
> 
> Hi All,
> 
> I have hunted high and low and tried dozens of things but have yet to
> achieve the result I require. Below is my code (taken mostly from another
> thread on here) thus far:
> 
> files<-list.files()
> files<-files[grep('.wm4', files)]
> labels<-gsub('.wm4', '',files)
> 
> for(i in 1:length(files)){
> X<-read.table(files[i])
> <My problem is here!>
> 
> What I am trying to do now is assign the first item in labels in place of
> X so the table name will effectively be whatever is written in labels[1].
> The files simply consist of two columns of real numbers. I have tried
> several things, such like replacing X with labels[1], but this simply
> writes the data in one long column to the first place of labels(which
> makes sense). How do I extract what is in labels[1] and set it as the
> table name?
> 
> As always any help is greatly appreciated.
> 
> Kenny Larsen
> 

-- 
View this message in context: http://www.nabble.com/Assigning-Data-a-name-from-within-another-variable--tp24037279p24054319.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list