[R] Loop over rda list files and using the attach function

Juan Ceccarelli Arias jfca283 at gmail.com
Wed Aug 31 22:45:11 CEST 2016


Hi
I want to comment something.
When i added the detach(get(yyz)) the RAM consumption was considerable
reduced.
So, i want to declare this issue as solved and thank you all for your
assistance.
Good luck to all.

On Tue, Aug 30, 2016 at 6:24 PM, Juan Ceccarelli Arias <jfca283 at gmail.com>
wrote:

> The attach(get(yyz)) option i tried and it worked. The only issue, is that
> when i'm  trying to export the results, it takes a lot of time.
> Considerably more than Stata. Also, the computer almost collapses for a
> task which isn't so exhausting for my PC station.
> Im dubious...
>
> On Tue, Aug 30, 2016 at 3:42 PM, <ruipbarradas at sapo.pt> wrote:
>
>> Hello,
>>
>> Try
>>
>> attach(get(yyz))
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>>
>>
>>
>>
>>
>>
>> Citando Juan Ceccarelli Arias <jfca283 at gmail.com>:
>>
>> Hi.
>>> I need to loop over rda files.
>>> I generated the list of them.
>>> That's ok. The problem is that the name of the files are as yyyy_mm (eg
>>> 2010_01 is january or 2010, 2016_03 is march of 2016).
>>> So, when i try to use the attach function to create a simple table(age,
>>> sex) it fails.
>>> The only way to attach a file as is using
>>> attach(`2016_03`)
>>> The text above i have no idea how to declare it in my code below
>>>
>>>
>>> dd=list.files("C:/Users/Me/r", pattern="rda$", full.names=F)
>>> for (i in 1:length(dd)) {
>>> yyz=load(dd[i])
>>> attach(yyz)
>>> table(age, sex)
>>> rm(list=yyz)
>>>
>>> }
>>> This is the error it declares the loop:
>>> Error in attach(yyz) : file '2013_02' not found
>>>
>>>
>>> Thanks for your help and time
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list