标签: grouped-table

Dplyr - 按组变量排列groups_df不起作用

我有一个data.frame,其中包含每年的客户名称,年份和几个收入数字.

df <- data.frame(client = rep(c("Client A","Client B", "Client C"),3), 
                 year = rep(c(2014,2013,2012), each=3), 
                 rev = rep(c(10,20,30),3)
                )
Run Code Online (Sandbox Code Playgroud)

我希望最终得到一个data.frame,它按客户和年份汇总收入.然后我想逐年对data.frame进行排序,然后按收入递减.

library(dplyr)
df1 <- df %>% 
        group_by(client, year) %>%
        summarise(tot = sum(rev)) %>%
        arrange(year, desc(tot))
Run Code Online (Sandbox Code Playgroud)

但是,当使用上面的代码时,arrange()函数根本不会改变分组data.frame的顺序.当我运行以下代码并强制执行正常的data.frame时,它可以工作.

   library(dplyr)
    df1 <- df %>% 
            group_by(client, year) %>%
            summarise(tot = sum(rev)) %>%
            data.frame() %>%
            arrange(year, desc(tot))
Run Code Online (Sandbox Code Playgroud)

我是否遗漏了某些东西,或者每次尝试arrange按分组变量分组_df 时是否需要这样做?

R版本:3.1.1 dplyr软件包版本:0.3.0.2

编辑11/13/2017 : 正如lucacerone所述,从dplyr 0.5开始,在排序时再次安排忽略组.所以我的原始代码现在以我最初预期的方式工作.

arrange()再次忽略分组,恢复到dplyr 0.3及更早版本的行为.这使得arrange()与其他dplyr动词不一致,但我认为这种行为通常更有用.无论如何,它不会再发生变化,因为更多的变化只会引起更多的混乱.

r grouped-table dplyr

31
推荐指数
2
解决办法
3万
查看次数

viewForHeaderInSection的框架总是大小相同

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{

 if(section != 0) {

  UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 30)] autorelease];
  view.backgroundColor = [UIColor redColor];

  return view;

 } else {
  return tableView.tableHeaderView;
 }
Run Code Online (Sandbox Code Playgroud)

}

这是我对viewForHeaderInSection的实现,但无论我做什么帧,它总是向我显示相同的红框.你看到我的代码有什么问题吗?

图片:

在此输入图像描述

更新:

嗯,现在我的红色区块更高,但我的第一个桌面现在以某种方式隐藏了.第一个是使用titleForHeaderInSection实现的.我以为我只是实现tableHeader高度的高度,但这不起作用

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 1)
    return 30;
else
    return tableView.tableHeaderView.frame.size.height;
}
Run Code Online (Sandbox Code Playgroud)

iphone uitableview grouped-table

18
推荐指数
1
解决办法
2万
查看次数

iPhone:形成新的联系方式

我对Apple iPhone Contact App有一些疑问.我想使用相同的方法来创建和修改信息.

这是两个图片:

alt text http://grab.by/4ZjQ alt text http://grab.by/4ZjR

所以我们有创作和版本.该表单看起来像一个带有groupsStyle的UITableView,但我不知道如何重新创建所有这些.您是否有想法或教程可以解释如何做到这一点?

非常感谢 !

iphone contact uitableview grouped-table

14
推荐指数
1
解决办法
5816
查看次数

分组tableview中不同高度的节头

得到了一个默认的分组样式表,如下面的左侧屏幕截图,但它看起来有不同的节标题高度,顶部首先是69 px测量,而其余的是40 px.

为什么?它们应该是相同的高度,不是吗?

所以我想用它的方法制作它们tableView:heightForHeaderInSection:,return 40

但是.....看起来更糟糕!即使将章节标题放在......如右下图所示,它也会放大高于中间的高度.

在此输入图像描述

我只想拥有相同高度的节头.如何使它工作?

height uitableview grouped-table sectionheader

9
推荐指数
1
解决办法
4195
查看次数

更改表格视图(tableview样式分组)背景颜色?

我正在开发一个iPad应用程序,我需要一个表格视图(样式分组),背景颜色为clearColor.

我的问题是

[self.tableView setBackgroundColor:[UIColor clearColor]];
Run Code Online (Sandbox Code Playgroud)

如果表视图样式是普通的,但是当我切换到组表视图时,背景颜色不会改变,它会保持灰色.

仅供参考:tableviewcell的contentview背景颜色也不会改变.

这是iPhone-sdk中的错误还是我做错了什么.

uitableview grouped-table ipad iphone-sdk-3.2

8
推荐指数
1
解决办法
7454
查看次数

R:计算由id变量和基于时间的窗口分组的不规则时间序列的滚动总和

我喜欢R,但有些问题很难解决.

挑战在于在具有大于或等于6小时的基于时间的窗口的不规则时间序列中找到小于30的滚动总和的第一个实例.我有一个系列的样本

Row Person  DateTime    Value
1   A   2014-01-01 08:15:00 5
2   A   2014-01-01 09:15:00 5
3   A   2014-01-01 10:00:00 5
4   A   2014-01-01 11:15:00 5
5   A   2014-01-01 14:15:00 5
6   B   2014-01-01 08:15:00 25
7   B   2014-01-01 10:15:00 25
8   B   2014-01-01 19:15:00 2
9   C   2014-01-01 08:00:00 20
10  C   2014-01-01 09:00:00 5
11  C   2014-01-01 13:45:00 1
12  D   2014-01-01 07:00:00 1
13  D   2014-01-01 08:15:00 13
14  D   2014-01-01 14:15:00 15

For Person A, Rows …
Run Code Online (Sandbox Code Playgroud)

r time-series grouped-table

6
推荐指数
1
解决办法
990
查看次数

以编程方式创建分组UITableView

我有一个UITableViewController,当前显示4个单元格,将始终显示,并希望将它们组合在一起,但我无法弄清楚如何.我发现的资源仅在通过UIViewController或其他类似的东西插入标准UITableView时使用Interface Builder提供指令.如何以编程方式对它们进行分组?

这是我当前的UITableViewController类:

import UIKit

class SecondViewController: UITableViewController {

    let Items = ["Altitude","Distance","Groundspeed"]

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.Items.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
        cell.textLabel?.text = self.Items[indexPath.row]
        return cell
    }


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
    }

}
Run Code Online (Sandbox Code Playgroud)

uitableview grouped-table swift

6
推荐指数
1
解决办法
1万
查看次数

在Viewcontroller中显示带有图像和标签的Headerview

我是iPhone开发的新手.我创建了一个视图控制器,我使用了分组表视图.现在我想在viewcontroller中显示包含图像和标签的标题视图.请指导我,帮助我解决这个问题.

谢谢.

iphone objective-c grouped-table http-headers

5
推荐指数
1
解决办法
1533
查看次数

[iPhone]如何在分组TableView中自定义Section的标题?

为了自定义单元格,我们实现了类继承UITableViewCell.现在,要在分组的UITableView中定制Section的标题(与下图相同),该怎么办?请指导我!
替代文字

iphone uitableview grouped-table

4
推荐指数
2
解决办法
5433
查看次数