samples = Data
Result <- NULL
for(WAFERPART in unique(samples$WAFER)) {
rawDataPart<-subset(samples, WAFER == WAFERPART )
length<- nrow(rawDataPart)#wafer data count
rawDataPart$rank <- NA
rawDataPart$qnorm <- NA
rawDataPart$waferCount <- NA
rawDataPart$rank[order(rawDataPart$x)] <- 1:nrow(rawDataPart)
rawDataPart$qnorm<-qnorm(rawDataPart$rank/(length+1))
rawDataPart$waferCount<-length
newData<-rawDataPart
data <- rawDataPart$x
colnames(newData) <- c('parameter','rawData','wafer','rank','gnorm','waferCount')
if(is.null(Result)) { Result <- newData }
else { Result = rbind(Result, newData) }
}