[R] assign vectors to objects

John linux-user
Wed, 01 Aug 2012 15:50:55 -0000

Hi everyone,

I try to add many vectors (L1,L2,L3....) to multiple list objects (a.list,
b.list....) in a workspace. Somethings like below, but it is not
working. Any suggestions will be appreciated. Best, John



lf=ls(pattern=".lst")

 for (x in listfiles) {
    dat=read.delim(x,header=F)


    for (i in lf) {
    assign(i$add,as.numeric(dat[,3]))
  #or i$add=as.numeric(dat[,3]
    names(i)[names(i)=="add"]=substr(x,1,5)

    print (i[1:3,])
 }}






________________________________
 From: "r-help-bounces@r-project.org"
<r-help-bounces@r-project.org>

Sent: Wednesday, August 1, 2012 11:11 AM
Subject: Your message to R-help awaits moderator approval

Your mail to 'R-help' with the subject

    add vectors to multiple objects

Is being held until the list moderator can review it for approval.

The reason it is being held:

    Post to moderated list

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.  If you would like to cancel
this posting, please visit the following URL:


https://stat.ethz.ch/mailman/confirm/r-help/4bdc02c25f8cb618a623fce61b61fb51189c52ad
	[[alternative HTML version deleted]]