rank() would do it: > x <- c(1,2,2,2,2,3,4,4,5,5) > rank(x, ties="max")/length(x) * 100 [1] 10 50 50 50 50 60 80 80 100 100 as would ecdf() > ecdf(x)(x)*100 [1] 10 50 50 50 50 60 80 80 100 100
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of greggal...@gmail.com > Sent: Sunday, November 04, 2012 7:22 PM > To: r-help@r-project.org > Subject: [R] Replace array with percentile values > > Hi: > > I have an array of measurements, that I've been doing linear > regression model and AI models on. Because there are many errors and > the values are "ill-formed" I would like to copy the array, but > replace each value with the PERCENTILE of that value, in the original > array. > > i.e. > > mesments$V1: 9, 77, -1 > > would become: mesmentsCopy$V1: 50, 100, 0 > > The actual array has many more rows and columns, of course. > > Cheers, > > Greg Allen > Freelance Techno-Slave > SLC, Utah > > ______________________________________________ > 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.