[R] Dealing with a lot of parameters in a function

Wu Gong wg2f at mtmail.mtsu.edu
Mon Aug 2 18:04:16 CEST 2010


Hi,

Putting all parameters into a data frame would help.

Code like:

parameters <-
data.frame(mu=1:24,b=(1:24)*2,tau=(1:24)/2,sigma=(1:24)^2,ro=sqrt(1:24))

ll<- function(parameters){
	results <- numeric(24)
	for (i in 1:24){
	mu <- parameters$mu[i]
	b <- parameters$b[i]
	.....
	results[i] <- sum(mu*b)
	}
	results
}
sum(results)

-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/Dealing-with-a-lot-of-parameters-in-a-function-tp2310384p2310468.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list