Hi [EMAIL PROTECTED] napsal dne 22.10.2007 14:01:14:
> Hi, > > I need to calculate either Error or Normalized values based on the following > principle: > > Error = Observed value - reference value > Normalized value = Observed Value - Part average > > appraiser <- rep(rep(1:3,c(3,3,3)),10) > trail <- rep(rep(1:3,3),10) > part <- rep(1:10,c(9,9,9,9,9, 9,9,9,9,9)) > value <- c(rnorm(9, 57.01,0.01), rnorm(9, 57.06,0.02), rnorm(9, 57.10,0.04), > rnorm(9, 57.07,0.03), rnorm(9, 57.12,0.025), > rnorm(9, 57.02,0.011), rnorm(9, 57.03,0.02), rnorm(9, 57.08, > 0.013), rnorm(9, 57.01,0.06), rnorm(9, 57.03,0.015)) > off <- cbind(appraiser, trail, part, value) > off <- data.frame(off) > off$appraiser <- factor(off$appraiser) > off$trail <- factor(off$trail) > off$part <- factor(off$part) > > par(mfrow=c(1,2)) > boxplot(off$value ~ off$part) > > ## when nicely ordre calculation of error is easy > reference <- rep(c(57.01, 57.06, 57.10, 57.07, 57.12, 57.02, 57.03, 57.08, > 57.01, 57.03), c(9,9,9,9,9, 9,9,9,9,9)) > off$error <- off$value - reference > boxplot(off$error ~off$part) Is off$err<-do.call(c,tapply(off$value,off$part,function(x) x-mean(x))) what you want to do? Regards Petr > > > > > This is a constructed example. > > How do I find mean for the 10 individual parts and make a off$normalized > where I substract the mean for the part in the dataset from the individual > observed values in the data set? > > I would also like to find a good method to come from a data.frame/matrix > where part and reference value and even the avaerage find before where > listed, the reason is that the order of the data are not always as > structured: > > part reference mean > 1 57.01 57.0102 > 2 57.06 57.0612 > .... > > > -- > Klaus F. Řstergaard, <farremosen(at)gmail dot com> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.