Displaying 20 results from an estimated 1000 matches similar to: "A better way to Rank Data that considers "ties""
2012 Jul 12
3
Add row into a Matrix witout headers from Function
Hi,
Here i have a matrix like this,
OLDMatrix <-
X1 X2 X3
----- ------ ------
22 24 23
25 27 27
10 13 15
the thing is,
im running two function(SUM,COUNT) to get output in another matrix called
NEWMatrix
NEWMatrix <- c("SUM",colSums(OLDMatrix ))
NEWMatrix <- c("COUNT",colSums(!is.na(OLDMatrix
2007 Aug 24
1
uneven list to matrix
Hello,
I am sure I am not the only person with this problem.
I have a list with n elements, each consisting of a single column matrix
with different row lengths. Each row has a name ranging from A to E. Here
is an example:
alph[[1]]
A 1
B 2
C 3
D 4
alph[[2]]
A 1
C 3
D 4
alph[[3]]
A 1
D 4
E 5
I would like to create a matrix from the elements in the list with n
columns such that the row names
2010 Jan 08
2
How to Merge based on Rows
Let's say that I have a bunch of matrices.
They look like this (pardon using fruit for examples, my actual data tables
are far too enormous):
Matrix1
Apples Oranges Pears
A 5 6 7
B 5 3 4
C 8 9 10
D 11 13 14
E 15 3 8
F 1 4 5
2007 Sep 14
1
Copying row names
I have been trying to copy the row names of one matrix to another matrix but
having difficulty. The original matrix contains a row name which I would
like to replicate in the new matrix. I use the following approach?
The two matrices have identical dimensions.
rN <- row.names(origMatrix)
row.names(newMatrix) <- rN
However the new matrix does not take on the labels.
I have also tried,
2005 Apr 21
1
large matrix
Dear R-users
I need to convert a matrix with three columns in a new array with
multiple columns.
For example,
oldmatrix
1 4 5
1 54 52
1 9 43
2 32 5
2 54 6
2 76 6
3 54 54
3 543 7
3 54 6
newmatrix
5 5 54
52 6 7
43 6 6
if the first column have a new value then add a column to the new
matrix and the new[i,j] <- old[,3][i]
I write this code, but my initial matrix is very
2007 Feb 27
5
Multiple conditional without if
Dear all,
i am stuck with a syntax problem.
i have a matrix which has about 500 rows and 6 columns.
now i want to kick some data out.
i want create a new matrix which is basically the old one except for all
entries which have a 4 in the 5 column AND a 1 in the 6th column.
i tried the following but couldn“t get a new matrix, just some wierd
errors:
2010 Jan 28
2
NA Replacement by lowest value?
Hi all,
I need to replace missing values in a matrix by 10 % of the lowest available value in the matrix. I've got a function I've used earlier to replace negative values by the lowest value, in a data frame, but I'm not sure how to modify it...
nonNeg = as.data.frame(apply(orig.df, 2, function(col) # Change negative values to a small value, close to zero
{
min.val =
2013 Oct 15
1
Problem with lapply
Hi together
I'm pretty new to R, so excuse me if it is a basic question.
I have a big dataset (extract of it found in the attachment) of returns from
firms. I'd like to compute the Pearson correlation of each firm with the
"Market" and the corresponding p-Value. So I thought of making a list of
'cor.test's and then extract the needed values with a for loop. What I did
so
2004 Sep 29
1
glm.fit and predict.glm: error ' no terms component'
Hi
when I fit a glm by
glm.fit(x,y,family = binomial())
and then try to use the object for prediction of newdata by:
predict.glm(object, newdata)
I get the error:
Error in terms.default(object) : no terms component
I know I can use glm() and a formula, but for my case I prefer
glm.fit(x,y)...
thanks for a hint
christoph
$platform
[1] "i686-pc-linux-gnu"
$arch
[1]
2003 Jul 22
1
rank with ties
Hi,
Is there a function like rank but that solves the ties by randomly assigning
a value (doesn't average ranks of ties).
This is what I actually need:
I want to make NA all elements of each column in an array that are ranked in
a position larger that rankmax for each column.
# Say I've got an array b:
b<-cbind(c(1:5,5:1),c(1,12,14,2,5,4:8))
#> b
# [,1] [,2]
#[1,] 1 1
2005 Dec 08
3
Reshaping data
Dear all,
given I have data in a data.frame which indicate the number of people in
a
specific year at a specific age:
n <- 10
mydf <- data.frame(yr=sample(1:10, size=n, replace=FALSE),
age=sample(1:12, size=n, replace=FALSE),
no=sample(1:10, size=n, replace=FALSE))
Now I would like to make a matrix with (in this simple example)
10 columns (for the
2011 Jun 16
1
Matching vector order by indicators in a matrix
Hi all~
I have a bit of stupid question. And I promise, I have struggled through this and it sort of pains me to post this question...
I have the following vector which is are the estimated parameter values output from "optim".
$Rates
[1] 0.006280048 0.330934659
I want to match the order in the vector by the number in the following matrix:
$Index.matrix
ALPHA 1 1
BETA 2
2005 Mar 18
2
logistic model cross validation resolved
This post is NOT a question, but an answer. For readers please disregard all earlier posts by myself about this question.
I'm posting for two reasons. First to say thanks, especially to Dimitris, for suggesting the use of errorest in the ipred library. Second, so that the solution to this problem is in the archives in case it gets asked again.
If one wants to run a k-fold cross-validation
2015 Oct 20
0
rank(, ties.method="last")
On Tue, Oct 20, 2015 at 10:26 AM, Henric Winell
<nilsson.henric at gmail.com> wrote:
> Den 2015-10-09 kl. 12:14, skrev Martin Maechler:
> I think so: the code above doesn't seem to do the right thing. Consider
> the following example:
>
> > x <- c(1, 1, 2, 3)
> > rank2(x, ties.method = "last")
> [1] 1 2 4 3
>
> That doesn't look right
2002 May 07
1
Problem with ties in rank()
Hello All:
I have a vector of data, z
> z
[1] 0.1 0.1 0.1 0.1 0.2 0.2 0.3 0.3 0.3 0.4 0.5 0.5 0.5 0.7
0.7 0.7 0.9 0.9 1.1
[20] 1.1 1.2 1.3 1.4
The first 4 elements have values of 0.1 followed 2 elements with values 0.2.
When I invoke rank(z), I expected to get (1+2+3+4)/4 = 2.5 for the first 4
elements in the ranking and (5+6)/2 = 5.5 for elements 5 and 6. But what I
do
2011 Nov 21
2
count ties after rank?
Hello!
I need to use Kruskal-Wallis test and post-hoc test (Dunn's test) for my data. But when I searched around, I only found this function: kruskal.test. But nothing for Dunn's test.
So I started to write one myself. But I do not know how to count ties in the data frame. I can use for loops but it seems long and unnecessary since the rank function actually knows the ties. So
2002 May 07
1
More on ties with rank()
I am grateful to Prof. Ripley for his explanation. Indeed, rounding explains
it all.
I take the difference between two vectors and call it "z"
method.a <- c(6.3, 6.3, 3.5, 5.1, 5.5, 7.7, 6.3, 2.8, 3.4, 5.7, 5.6, 6.2,
6.6,
7.7, 7.4, 5.6, 6.3, 8.4, 5.6, 4.8, 4.3, 4.2, 3.3,
3.8, 5.7, 4.1)
method.b <- c(5.2, 6.6, 2.3, 4.4, 4.1, 6.4, 5.4, 2.3, 3.2, 5.2, 4.9,
2015 Oct 21
2
rank(, ties.method="last")
Marius Hofert-4------------------------------
> Den 2015-10-09 kl. 12:14, skrev Martin Maechler:
> I think so: the code above doesn't seem to do the right thing. Consider
> the following example:
>
> > x <- c(1, 1, 2, 3)
> > rank2(x, ties.method = "last")
> [1] 1 2 4 3
>
> That doesn't look right to me -- I had expected
>
> >
2006 Aug 25
1
exact Wilcoxon signed rank test with ties and the "no longer under development" exactRanksumTests package
Dear List,
after updating the exactRanksumTests package I receive a warning that
the package is not developed any further and that one should consider
the coin package.
I don't find the signed rank test in the coin package, only the Wilcoxon
Mann Whitney U-Test. I only found a signed rank test in the stats
package (wilcox.test) which is able to calculate the exact pvalues but
unfortunately
2015 Oct 08
3
rank(, ties.method="last")
Hi,
I ran into a problem where I actually need rank(, ties.method="last"). It would
be great to have this feature in base and it's also simple to get (see below).
Thanks & cheers,
Marius
rank2 <- function (x, na.last = TRUE, ties.method = c("average",
"first", "last", # new "last"
"random", "max",