[R] assign vectors to objects

David Winsemius dwinsemius at comcast.net
Thu Aug 2 01:21:18 CEST 2012


On Aug 1, 2012, at 8:50 AM, John linux-user wrote:

> 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,])
>  }}


See the response to another very similar question from you. Please  
wait a decent interval (measured in days, not minutes) before posting  
very similar questions.

> ________________________________
> From: "r-help-bounces at r-project.org" <r-help-bounces at 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]]
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
Alameda, CA, USA



More information about the R-help mailing list