Skip to content

Efficient Way to gather data from various files

4 messages · Sam Asin, Rui Barradas, Jeff Newmiller

#
Hello,

There are more R friendly ways to do what you want, it seems to me easy 
to avoid loops but you need to tell us how do you know which rows 
correspond to the 50th and 90th quantiles. Maybe this comes from the 
value in some other column?

Give a bit more complete a description and we'll see what can be done.

Hope this helps,

Rui Barradas
Em 03-10-2012 00:33, Sam Asin escreveu:
#
File operations are not vectorizable. About the only thing you can do for the iterating through files part might be to use lapply instead of a for loop, but that is mostly a style change.

Once you have read the dbf files there will probably be vector functions you can use (quantile). Off the top of my head I don't know a function that tells you which value corresponds to a particular quantile, but you can probably sort the data with order(), find the value whose ecdf is just below your target with which.max, and look at the row number of that value.

x <- rnorm(11)
names(x) <- seq(x)
xs <- x[order(x)]
Row90 <- as.numeric(names (xs)[0.9<=seq(xs)/length(xs))])

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Sam Asin <asin.sam at gmail.com> wrote: