[R] Help -- feed data frames, returned from function into list --

Berend Hasselman bhh at xs4all.nl
Thu Mar 10 09:27:33 CET 2016

> On 10 Mar 2016, at 08:56, Sunny Singha <sunnysingha.analytics at gmail.com> wrote:
> Hi,
> I got a problem. Using loop, I'm trying to feed data frames, returned from
> the function, into the list but not all data frames are getting captured.
> I have vector with some string values which I want to pass to the function.
> *groups* <- c('cocacola', 'youtube','facebook)

You posted in HTML. In a plain text mailing list we see *groups* which is nonsense. You boldified?
Please do not do that and do not post in HTML.

> for(i in 1:length(groups)){
> g <- list()
> g[[i]] <- searchGroups_mod(*groups[i]*, token=fb_oauth, 10)
> }
> The result list stores data frame only for the last string in the 'groups'
> vector.
> Why the List is getting reassigned for each iteration ? Please guide.

Because you are creating the list g inside the loop.
Put the g <- list) before the loop.

> Regards,
> Sunny Singha.
> 	[[alternative HTML version deleted]]__

This is a plain text mailinglist. Do not post in HTML.


> ____________________________________________
> 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/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list