Percentile calculation based on a known percentile table I have two data about people's weights. One is from normal patients, and another is about patients with a specific disease. 
Let's say:
weight_Normals <- c(170, 140, 122, 143, 156, 122, 189, 200, 201, 133, 155, .....)
weight_Disease <- c(220, 145, 167, 177, 190, 130, 169, 100, 230, 210, 222, .....)

I can compute the percentile from 0.01 to 0.99 of weight_Normals. However, how should I use this percentile results from normal patient to map into the patients with diasease? In other words, I would like to calculate the percentile of these patients with disease based on the percentiles of normal patients.
 A: In other words, "what proportion of the first sample are less than or equal to a given observation in the second sample?"
apply(outer(weight_Normals,weight_Disease,"<="),2,sum)/length(weight_Normals)

Test:
weight_Normals <- c(170, 140, 122, 143, 156, 122, 189, 200, 201, 133, 155)
weight_Disease <- c(220, 145, 167, 177, 190, 130, 169, 100, 230, 210, 222)
apply(outer(weight_Normals,weight_Disease,"<="),2,sum)/length(weight_Normals)

 print(apply(outer(a,b,"<="),2,sum)/length(a),digits=4)
 [1] 1.0000 0.4545 0.6364 0.7273 0.8182 0.1818 0.6364 0.0000 1.0000 1.0000 1.0000

So for example, the second disease patient weighs at least as much as 45.45% of the first sample.

Alternative version to handle ties symmetrically
Consider if we had Normal patients with weights 137, 140, 151, 166 and 173, and disease patients with weights 150, 151 and 152.
The ones with weights 150 and 152 are easy enough. "150" is 2/5 of the way through the sample. It is at the 40th percentile of the other sample. Similarly, "152" is at the 60th percentile. But "151" is exactly equal to the median of the other sample. While a strict definition of cdfs would have us compute the proportion less than or equal to it (giving 0.6 or 60%), for exact equality it may make sense to estimate that as 50%. That would give the following calculation:
left <- apply(outer(weight_Normals,weight_Disease,"<"),2,sum)/length(weight_Normals)
right <- apply(outer(weight_Normals,weight_Disease,"<="),2,sum)/length(weight_Normals)

percent.wties <- (left+right)/2
print(percent.wties, digits=4)

(This gives the same answers as before on the example)

Smoothing considerations?
If your samples are small you might want to consider using smoother estimates of what the percentile ranks are than the sample proportions, either by fitting some assumed parametric form of distribution or by kernel density estimation. [This is occasionally done; if it doesn't sound like what you want, I wouldn't worry about it at all.]
