Displaying 1 result from an estimated 1 matches for "oregonash".
Did you mean:
oregon's
2009 Oct 21
1
How do I vectorize this loop....
...re error based on the Expected Mean (ie, Survival). The code looks
up the expectation for each zone and applies for each sample in the zone
using a loop:
Data1 <- data.frame(Sample=1:6, Live =c(24,25,30,31,22,23), Baseline =
c(35,35,35,32,34,33),Zone = c(rep("Cottonwood",3),rep("OregonAsh",3)))
Data2 <- data.frame(Zone = c("Cottonwood","OregonAsh"), Survival =
c(0.83,0.76))
for (i in 1:nrow(Data1)) #####(Yi -Ybar*Yo)^2
Data1$SquaredError[i] <- (Data1$Live[i] -
Data2$Survival[which(Data1$Zone[i]==Data2$Zone)]*Data1$Baseline[i])^2
My question is, ca...