Displaying 2 results from an estimated 2 matches for "x_sorted".
2011 Nov 18
1
R: writing data from one matrix into another with keeping NA's
...ust one additional line,
but it''s still bugging me and it will definitely come in handy at some time.
Best regards,
Karl
##Loading Packages
library(qpcR)
data = c(1,NA, 2, 3)
row=2
col=28
x <- matrix(data=data, nrow=row, ncol=col)
colnames(x) <- c(1:28)
x_sorted <- t(apply(x, 1, sort, decreasing=T, na.last=T))
q_list <- matrix(data = 0, nrow= nrow(x), ncol=1)
###################
##DETERMINING LENGTH OF THE QUINTILES
q <- apply((!is.na(x_sorted)),1, sum)
q_list[q_list==0] <- q
q_list = q_list/5
##Function to check wether q is...
2013 Mar 11
3
How to obtain the original indices of elements after sorting
Dear All,
Suppose I have a vector X = (x_1, x_2, ...., x_n), X_sort = sort(X)
= (x_(1), x_(2), ... , x(n) ),
and I would like to know the original position of these ordered x_(i)
in X, how can I do it?
case 1: all values are unique
x <- c( 3, 5, 4, 6)
x.sort <- sort(x) #
# I would like to obtain a vector (1, 3, 2, 4) which indicates that 3
in x is still the 1st element in x.sort, 5 is at