Hi All, I had 12766 elements in a column, 12566 are values and 200 are "NA"s. I used the following line to get the ranks: total_list$MB.rank <- rank(-total_list$MB,ties.method="min",na.last=NA) but I got an error message: Error in `$<-.data.frame`(`*tmp*`, "BCRP_PW_F.rank", value = c(3949, 6182, : replacement has 12199 rows, data has 12766 What shall I do to keep the "NA"s as "NA"s? thanks a lot. Jiong The email message (and any attachments) is for the sole use...{{dropped}}
Hi, try this: total_list$MB.rank[!is.na(toal_list$MB)] <- rank(-total_list$MB,ties.method"min",na.last=NA) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 17/08/07, Jiong Zhang, PhD <jizhang@chori.org> wrote:> > Hi All, > > I had 12766 elements in a column, 12566 are values and 200 are "NA"s. I > used the following line to get the ranks: > > total_list$MB.rank <- rank(-total_list$MB,ties.method="min",na.last=NA) > > but I got an error message: > > Error in `$<-.data.frame`(`*tmp*`, "BCRP_PW_F.rank", value = c(3949, > 6182, : > replacement has 12199 rows, data has 12766 > > What shall I do to keep the "NA"s as "NA"s? thanks a lot. > > Jiong > The email message (and any attachments) is for the sole use...{{dropped}} > > ______________________________________________ > R-help@stat.math.ethz.ch 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. >[[alternative HTML version deleted]]
On Fri, 17 Aug 2007, Jiong Zhang, PhD wrote:> Hi All, > > I had 12766 elements in a column, 12566 are values and 200 are "NA"s. I > used the following line to get the ranks: > > total_list$MB.rank <- rank(-total_list$MB,ties.method="min",na.last=NA) > > but I got an error message: > > Error in `$<-.data.frame`(`*tmp*`, "BCRP_PW_F.rank", value = c(3949, 6182, : > replacement has 12199 rows, data has 12766 > > What shall I do to keep the "NA"s as "NA"s? thanks a lot.If all else fails try reading the help! You have to select the right option for na.last, and yours is not it. I suspect you want na.last="keep", but only you know what you mean. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595