[R] How to use same function for diffrent input values
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Fri Feb 19 09:30:20 CET 2010
On Fri, Feb 19, 2010 at 8:20 AM, Madhavi Bhave <madhavi_bhave at yahoo.com> wrote:
> rates = indiv_rate(n = read.csv('number.csv')$n, rate_name = read.csv('rate.csv')$rate_name, rate = read.csv('rate.csv')$rate, rate_rf1 = read.csv('rate_rf.csv')$rate_rf1,
> rate_rf2 = read.csv('rate_rf.csv')$rate_rf2, rate_rf3 = read.csv('rate_rf.csv')$rate_rf3,
> rateprob1 = read.csv('rate_probability.csv')$probability1, rateprob2 = read.csv('rate_probability.csv')$probability2, rateprob3 = read.csv('rate_probability.csv')$probability3)
I'm not sure I understand your question fully, but this example above
shows me you have a few other things to learn. Don't do the same thing
more than once. Here you are reading the csv files several times.
That's horribly inefficient. Do it once, and store the value in a
variable:
rateprobthing = read.csv('file.csv')
and then use 'rateprobthing$whatever' each time. It'll make your code
faster and easier to understand.
For your question about different rates and whatnot, I don't think
it's clear where your different rates come from - is it a whole
different set of .csv files?
Barry
--
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman
More information about the R-help
mailing list