Hi I would like to normalize my data by one of the variables in long format. My data is like this:
> t1<-data.frame(id=rep(1:3,rep(3,3)),dt=rep(1:3,rep(9,3)),var=c('num1','num2','norm'),value=rnorm(27)) > t1 id dt var value 1 1 1 num1 -1.83276256 2 1 1 num2 1.57034303 3 1 1 norm 0.60008563 4 2 1 num1 -0.96893477 5 2 1 num2 0.30423346 6 2 1 norm -0.07044640 7 3 1 num1 -1.30558219 ... in this case there are 3 ids and 3 dates (dt). on each date, each id has a normalization factor given by the variable norm. i would like to divide all the variables for each id by the normalization on that date. (i don't care if the normalization is divided by itself since it should always be end up 1, might be a useful check.) so i would like to end up with a data frame like 1 1 num1 -1.83/.6 1 1 num2 -1.57/.6 2 1 num1 -.97/(-.07) 2 1 num2 .3/(-.07) etc. The actual data frame is quite long with about many id's and dates. Thanks! Neal [[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.