给定两组样本,比如:
A <- c(79.98, 80.04, 80.02, 80.04, 80, 80.03,
80.04, 79.97, 80.05, 80.03, 80.02, 80, 80.02)
B <- c(80.02, 79.94, 80, 79.97, 79.97, 80.03,
79.95, 79.97)
将这两组样本混合一起得到“合样本”,如何求各个样本观察值的在“合样本”中的秩,并且按在原来A,B中的顺序列出来?
如何用R软件求两个样本的混合秩?
本人已经找到答案了,愿意和大家分享:
x1 <- c(3, 1, 4, 15, 92)
x2 <- c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5)
names(x1)<-rep(letters[1],times=5)
names(x2)<-rep(letters[2],times=11)
(r2<-rank(c(x1,x2),ties.method="average"))
#其中ties.method有如下选项:ties.method = c("average", "first", "random", "max", "min"))