[R] Simplify simple code
Dong-hyun Oh
r.arecibo at gmail.com
Mon Apr 16 07:37:17 CEST 2007
Dear expeRts,
I would simplify following code.
---------------------------------------------
youtput <- function(x1, x2){
n <- length(x1)
y <- vector(mode="numeric", length=n)
for(i in 1:n){
if(x1[i] >=5 & x1[i] <= 10 & x2[i] >=5 & x2[i] <=10)
y[i] <- 0.631 * x1[i]^0.55 * x2[i]^0.65
if(x1[i] >=10 & x1[i] <= 15 & x2[i] >=5 & x2[i] <=10)
y[i] <- 0.794 * x1[i]^0.45 * x2[i]^0.65
if(x1[i] >=5 & x1[i] <= 10 & x2[i] >=10 & x2[i] <=15)
y[i] <- 1.259 * x1[i]^0.55 * x2[i]^0.35
if(x1[i] >=10 & x1[i] <= 15 & x2[i] >=10 & x2[i] <=15)
y[i] <- 1.585 * x1[i]^0.45 * x2[i]^0.35
}
y
}
----------------------------------------------
Anyone can help me?
Sincerely,
===========================================
Dong H. Oh
Ph. D Candidate
Techno-Economics and Policy Program
College of Engineering, Seoul National University,
Seoul, 151-050, Republic of Korea
E-mail:doriaba2 at snu.ac.kr
Mobile: +82-10-6877-2109
Office : +82-2-880-9142
Fax: +82-2-880-8389
More information about the R-help
mailing list