[R] call a variable from outside of for loop
bhh at xs4all.nl
Tue Apr 23 14:44:09 CEST 2013
On 23-04-2013, at 14:19, eliza botto <eliza_botto at hotmail.com> wrote:
> Dear Rui,it worked.......thanks indeed for you timely responce
In the original post you mentioned that e only held the first row.
But with what you showed I would have expected e to hold the last number printed.
So it's still unclear what you wanted to do or you didn't explain in enough detail what you were doing.
Which is why I asked for a reproducible example which you have not provided.
>> Date: Tue, 23 Apr 2013 13:09:58 +0100
>> From: ruipbarradas at sapo.pt
>> To: eliza_botto at hotmail.com
>> CC: r-help at r-project.org
>> Subject: Re: [R] call a variable from outside of for loop
>> It seems that you're recreating the variable 'e' every time through the
>> loop. In the end you only have 1 row. Try to create it outside the loop,
>> e <- vector("list", 35)
>> Then inside the loop
>> e[[i]] <- print(...)
>> Hope this helps,
>> Rui Barradas
>> Em 23-04-2013 12:21, eliza botto escreveu:
>>> Dear useRs,
>>> While using print command in "for" loop, i designated a variable being printed by "e". Although the output was shown inside the loop but when i tried to call the variable outside the loop it only gave the first row, where as it should have 35 rows as it showed inside loop.The command which i used in the loop is
>>> Kindly help me on it..
>>> [[alternative HTML version deleted]]
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> 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