This sounds like a perfect use of "list" and the 'sapply/lapply' functions:

> # list with 100 dataframes
> df.list <- lapply(1:100,function(x) data.frame(a=1:10, b=1:10))
> # create a new list with a random value of 'a'
> new.list <- sapply(df.list, function(x) sample(x$a, 1))
>
>
> new.list
  [1]  5  8 10  4  8 10  3  7  2  3  4  1  4  9  4  5  6  5  2  9  7  8  2
8  5  9  7  8  6  6  8  1  5  8  7
 [36]  5  9  5  3  1  1  4  6  7  5 10  3  5  4  7  3  5  8  1  9  4  9  4
4  5  9  9  4  8 10  5  8  4  4  8
 [71]  3  8  2  3  2  3  1  7  9  8  8  5  5  9  7  7  4  3 10  7  3  2  5
10  6 10  8  4  5  2
>


On Tue, May 18, 2010 at 5:28 PM, Q <quagaars@gmail.com> wrote:

>
> Hello!
>
>
> I'm having trouble figuring out how to apply a function to a set of vectors
> or data frames, when that set is over 1000 large.
>
>
> I've created 1891 vectors named as follows:
>
>
> vector.names <- paste("vector",1:1891,sep="")
>
>
> These can be referred to easily by using get as follows:
>
>
> vector <- get(vector.names[1])
>
>
> The problem is, I can't figure out a way to refer to all of them as a
> group,
> and then apply a function to each one.  Basically, I have 5000 data frames,
> each with 1891 rows.  I want a vector for each row, and a cell from each
> data frame in each vector.  That would give me 1891 vectors with 5000
> members each.  The only way I know how to do this, is to use loops, which
> end up being really slow.
>
>
> So:
>
>
> for(a in 1:5000){
>
> data <- get(dataframes[a])
>
>
> for(b in 1:1891){
>
> vector <- get(vector.names[b]
>
> vector[a] <- data$value
>
> assign(vector.names[b], vector)
>
> }
>
>
> }
>
>
> Does anyone have any insight into dealing with large quantities of data
> like
> this?
>
>
> Thanks!
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Dealing-with-1000-sequentially-named-vectors-tp2221942p2221942.html
> Sent from the R help mailing list archive at Nabble.com.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

	[[alternative HTML version deleted]]

