在矩阵中查找顶部值的行和列索引

时间:2016-04-20 16:28:19

标签: r matrix

矩阵中最大值的位置(行和列)可以通过以下方式找到:

ma <- matrix(1:50, nrow = 5)
which(ma == max(ma), arr.ind = TRUE)

如果我们不仅仅想要最大坐标而是N个最高值的坐标怎么办?

类似的东西:

order(ma, arr.ind = TRUE, decreasing = TRUE)[1:N] # this does not exist :(

1 个答案:

答案 0 :(得分:4)

<asp:Panel ID="PanelRoomDetail" runat="server" style="position:absolute; width:600px; height: 600px; display:none">
    <telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1" SelectedIndex="0" >
        <Tabs>
            <telerik:RadTab Text="Assign" Width="200px"></telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage runat="server" ID="RadMultiPage1"  SelectedIndex="0">
        <telerik:RadPageView runat="server" ID="RadPageView2">
            <div style="width: 600px; height: 200px; ">
                <div style="width: 600px;">
                    <asp:DataList ID="DataListFloorThumb" runat="server" RepeatColumns="5" >
                        <ItemTemplate>
                            <div style="width:72px;height:72px">
                            <asp:LinkButton id="LinkButton1" runat="server">

                                <div style='background-image:url(<%# Eval("image_path","Styles/Images/{0}") %>)'>
                                    <div style="overflow: hidden;">
                                        <div style="text-align: left; float:left;">
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("RoomNum")%>' CommandName="cmd_RoomNum" CommandArgument='<%# Eval("RoomNum")%>' Font-Names="Calibri" Font-Size="11pt"></asp:Label>
                                        </div>
                                    </div>
                                </div>
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:DataList>
                </div>
            </div>
            <div>
                <div>
                    <asp:TextBox ID="TextBoxRoomNum" runat="server"></asp:TextBox>
                </div>
            </div>
        </telerik:RadPageView>
    </telerik:RadMultiPage>
</asp:Panel>