rank

Find top deciles from dataframe by group

不打扰是莪最后的温柔 提交于 2019-12-02 11:39:15
问题 I am attempting to create new variables using a function and lapply rather than working right in the data with loops. I used to use Stata and would have solved this problem with a method similar to that discussed here. Since naming variables programmatically is so difficult or at least awkward in R (and it seems you can't use indexing with assign ), I have left the naming process until after the lapply . I am then using a for loop to do the renaming prior to merging and again for the merging.

Using MySQL, how do I select query result rank of one particular row?

☆樱花仙子☆ 提交于 2019-12-02 09:46:04
问题 I've spent quite a lot of time today trying various things, but none of them seem to work. Here's my situation, I'd like to be able to select the rank of a row based on it's ID from a specifically sorted row For example, if my query is something like: SELECT id, name FROM people ORDER BY name ASC with results like: id name 3 Andrew 1 Bob 5 Joe 4 John 2 Steve I would like to get the rank (what row it ends up in the results) without returning all the rows and looping throw them until I get to

Implementing a total order ranking in PostgreSQL 8.3

只谈情不闲聊 提交于 2019-12-02 07:48:57
The issue with 8.3 is.....rank is introduced in 8.4. consider the numbers [10,6,6,2] I wish to achieve a rank of those numbers where the rank is equal to the the row number Rank,score 1, 10 2,6 3,6 4,2 A partial solution is to self join and count items with a higher or equal, score. this produces 1,10 3,6 3,6 4,2 this is not what I want. Is there a way to rank, or even just order by score then somehow extract the row number? If you want a row number equivalent to the window function row_number() , you can improvise in version 8.3 with a (temporary) SEQUENCE : CREATE TEMP SEQUENCE foo; SELECT

Find top deciles from dataframe by group

只谈情不闲聊 提交于 2019-12-02 05:32:41
I am attempting to create new variables using a function and lapply rather than working right in the data with loops. I used to use Stata and would have solved this problem with a method similar to that discussed here . Since naming variables programmatically is so difficult or at least awkward in R (and it seems you can't use indexing with assign ), I have left the naming process until after the lapply . I am then using a for loop to do the renaming prior to merging and again for the merging. Are there more efficient ways of doing this? How would I replace the loops? Should I be doing some

R - extracting value by rank

一个人想着一个人 提交于 2019-12-02 03:40:06
Suppose I have a data frame that I have ordered according to the Value column and now looks something like this: Name Value A 2 B 2 C 5 D 5 E 10 F 12 I am writing a function where one argument is a rank (e.g. rank=2) and I want the output to be the corresponding name (e.g. C & D). Any ties should be ranked equally. I would really appreciate any guidance as I've tried multiple ways of accomplishing this and keep getting errors of some sort. We can convert the Value as factor and then convert it into numeric to get equal ranks for same numbers getRank <- function(rank) { df$Name[as.numeric

Impact on NHibernate caching for searches with results including calculated value mapped as a formula (e.g. rank)

六眼飞鱼酱① 提交于 2019-12-02 03:17:22
问题 When defining a calculated property using a formula in NHibernate, what are the implications for when the formula varies its result depending on the query restrictions, especially with regards to query caching? More specifically, consider the following simple C# class: public class Entity { public Entity() { } public virtual int Id { get; protected set; } public virtual string Key { get; protected set; } public virtual string Value { get; protected set; } public virtual int Rank { get;

How to sort and rank a vector in C++ (without using C++11)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 03:07:01
问题 I am trying to construct a function take takes a vector, ranks it, sorts it and outputs the sorted and ranked vector with the original positioning of the values. For example: Input: [10,332,42,0.9,0] Output: [3, 5, 4, 2, 1] I used this stack overflow question (specifically Marius' answer) as a reference guide, however I am stuck with my code now and do not understand where the issue is. I am running a C++03. One of the errors I get is error: invalid types ‘const float*[float]’ for array

Query to rank rows in groups

岁酱吖の 提交于 2019-12-02 02:54:25
问题 I'm using Apache Derby 10.10. I have a list of participants and would like to calculate their rank in their country, like this: | Country | Participant | Points | country_rank | |----------------|---------------------|--------|--------------| | Australia | Bridget Ciriac | 1 | 1 | | Australia | Austin Bjorklun | 4 | 2 | | Australia | Carrol Motto | 7 | 3 | | Australia | Valeria Seligma | 8 | 4 | | Australia | Desmond Miyamot | 27 | 5 | | Australia | Maryjane Digma | 33 | 6 | | Australia |

Query to rank rows in groups

自作多情 提交于 2019-12-02 01:08:48
I'm using Apache Derby 10.10. I have a list of participants and would like to calculate their rank in their country, like this: | Country | Participant | Points | country_rank | |----------------|---------------------|--------|--------------| | Australia | Bridget Ciriac | 1 | 1 | | Australia | Austin Bjorklun | 4 | 2 | | Australia | Carrol Motto | 7 | 3 | | Australia | Valeria Seligma | 8 | 4 | | Australia | Desmond Miyamot | 27 | 5 | | Australia | Maryjane Digma | 33 | 6 | | Australia | Kena Elmendor | 38 | 7 | | Australia | Emmie Hicke | 39 | 8 | | Australia | Kaitlyn Mund | 50 | 9 | |

Impact on NHibernate caching for searches with results including calculated value mapped as a formula (e.g. rank)

别来无恙 提交于 2019-12-01 22:53:34
When defining a calculated property using a formula in NHibernate, what are the implications for when the formula varies its result depending on the query restrictions, especially with regards to query caching? More specifically, consider the following simple C# class: public class Entity { public Entity() { } public virtual int Id { get; protected set; } public virtual string Key { get; protected set; } public virtual string Value { get; protected set; } public virtual int Rank { get; protected set; } } Mapped with the following simple NHibernate mapping: <class name="Entity" mutable="false">