Skip to content
Back to formatted view

Raw Message

Message-ID: <5.2.0.9.0.20040115142509.00bafce8@kiev.biotech.kth.se>
Date: 2004-01-15T13:35:36Z
From: Johan Lindberg
Subject: A language technical question.

If I have 100 objekts in a folder and I prefer not to load them manually I 
wonder how I do this in R if using a for-loop.

I was thinking initially to do something like this:

infiles <- dir(pattern=".RData")
for(i in length(infiles))
         {
         load(infiles[i])
         paste("kalle", i, sep="") <- saveLoadReference
         }

But the line """paste("kalle", i, sep="")""" does not do it for me. I get 
the error message "Error: Target of assignment expands to non-language object"

The thing that I do not master is how to create a name in a for-loop that I 
can assign something to. And I want to be able to change that name as the 
loop goes on. I want to create in this case
kalle1
kalle2
kalle3
...
kalle100

and they should all represent the objects that I opened with load(infiles[i])


Best regards

/ Johan



*******************************************************************************************
Johan Lindberg
Royal Institute of Technology
AlbaNova University Center
Stockholm Center for Physics, Astronomy and Biotechnology
Department of Molecular Biotechnology
106 91 Stockholm, Sweden

Phone (office): +46 8 553 783 45
Fax: + 46 8 553 784 81
Visiting adress: Roslagstullsbacken 21, Floor 3
Delivery adress: Roslagsv?gen 30B