更改栏标题

时间:2019-03-07 10:46:05

标签: r

我在伦敦有一些基本的房价数据。

我有数据的子集

Y2018 = subset(HP, Date == "2018" & PPDCategory.Type == "A")

然后,我生成了交易价格的平均值,中位数,最大值和最小值。

Year2018 = as.data.frame(tapply(Y2018$Price, Y2018$Ward, na.rm=TRUE, median))
Year2018$mean = (tapply(Y2018$Price, Y2018$Ward, na.rm=TRUE, mean))
Year2018$max = (tapply(Y2018$Price, Y2018$Ward, na.rm=TRUE, max))
Year2018$min = (tapply(Y2018$Price, Y2018$Ward, na.rm=TRUE, min))

这显然现在将第一列显示为“ tapply(Y2018 $ Price,Y2018 $ Ward,na.rm = TRUE,中位数)”-使该列名称存储为“中位数”的正确方法是什么。 / p>

tapply(Y2018$Price, Y2018$Ward, na.rm = TRUE, median)     mean     max    min
                                                                              375000 338600.0  460000 133000
Cann Hall Ward                                                                462000 451264.2  690000 205000
Cathall Ward                                                                  489000 482119.1  775000 175000
Chapel End Ward                                                               460000 451798.3  773500 162500

1 个答案:

答案 0 :(得分:0)

对不起,我读错了,这里的问题答案是: Changing column names of a data frame

如果我理解您的问题,您可以按照以下方式使用tidyverse

onCreate()