[R] assign vectors to objects
R. Michael Weylandt
michael.weylandt at gmail.com
Thu Aug 2 01:09:03 CEST 2012
I'm afraid I don't quite understand what you're getting at: can you
say what you're trying to do big-picture wise.
This advice might help making a reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
Best,
Michael
PS -- Just a hunch -- but you might night the "get" function as well
as assign()
On Wed, Aug 1, 2012 at 10:50 AM, John linux-user
<johnlinuxuser at yahoo.com> 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,])
> }}
>
>
>
>
>
>
> ________________________________
> 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.
>
More information about the R-help
mailing list