带有POSIXct值的第一行到colnames

时间:2016-03-02 21:21:45

标签: r posix

我的数据框的第一行如下所示:

incoming_matrix[1,]
                          V1                  V2                  V3                  V4
interval 2015-10-08 00:00:00 2015-10-08 00:10:00 2015-10-08 00:20:00 2015-10-08 00:30:00
                          V5                  V6                  V7                  V8
interval 2015-10-08 00:40:00 2015-10-08 00:50:00 2015-10-08 01:00:00 2015-10-08 01:10:00
                          V9                 V10                 V11                 V12
interval 2015-10-08 01:20:00 2015-10-08 01:30:00 2015-10-08 01:40:00 2015-10-08 01:50:00
                         V13                 V14                 V15                 V16
interval 2015-10-08 02:00:00 2015-10-08 02:10:00 2015-10-08 02:20:00 2015-10-08 02:30:00
                         V17                 V18                 V19                 V20
interval 2015-10-08 02:40:00 2015-10-08 02:50:00 2015-10-08 03:00:00 2015-10-08 03:10:00
                         V21                 V22                 V23                 V24
interval 2015-10-08 03:20:00 2015-10-08 03:30:00 2015-10-08 03:40:00 2015-10-08 03:50:00
                         V25                 V26                 V27                 V28
interval 2015-10-08 04:00:00 2015-10-08 04:10:00 2015-10-08 04:20:00 2015-10-08 04:30:00
                         V29                 V30                 V31                 V32
interval 2015-10-08 04:40:00 2015-10-08 04:50:00 2015-10-08 05:00:00 2015-10-08 05:10:00
                         V33                 V34                 V35                 V36
interval 2015-10-08 05:20:00 2015-10-08 05:30:00 2015-10-08 05:40:00 2015-10-08 05:50:00
                         V37                 V38                 V39                 V40
interval 2015-10-08 06:00:00 2015-10-08 06:10:00 2015-10-08 06:20:00 2015-10-08 06:30:00
                         V41                 V42                 V43                 V44
interval 2015-10-08 06:40:00 2015-10-08 06:50:00 2015-10-08 07:00:00 2015-10-08 07:10:00
                         V45                 V46                 V47                 V48
interval 2015-10-08 07:20:00 2015-10-08 07:30:00 2015-10-08 07:40:00 2015-10-08 07:50:00
                         V49                 V50                 V51                 V52
interval 2015-10-08 08:00:00 2015-10-08 08:10:00 2015-10-08 08:20:00 2015-10-08 08:30:00
                         V53                 V54                 V55                 V56
interval 2015-10-08 08:40:00 2015-10-08 08:50:00 2015-10-08 09:00:00 2015-10-08 09:10:00
                         V57                 V58                 V59                 V60
interval 2015-10-08 09:20:00 2015-10-08 09:30:00 2015-10-08 09:40:00 2015-10-08 09:50:00
                         V61                 V62                 V63                 V64
interval 2015-10-08 10:00:00 2015-10-08 10:10:00 2015-10-08 10:20:00 2015-10-08 10:30:00
                         V65                 V66                 V67                 V68
interval 2015-10-08 10:40:00 2015-10-08 10:50:00 2015-10-08 11:00:00 2015-10-08 11:10:00
                         V69                 V70                 V71                 V72
interval 2015-10-08 11:20:00 2015-10-08 11:30:00 2015-10-08 11:40:00 2015-10-08 11:50:00
                         V73                 V74                 V75                 V76
interval 2015-10-08 12:00:00 2015-10-08 12:10:00 2015-10-08 12:20:00 2015-10-08 12:30:00
                         V77                 V78                 V79                 V80
interval 2015-10-08 12:40:00 2015-10-08 12:50:00 2015-10-08 13:00:00 2015-10-08 13:10:00
                         V81                 V82                 V83                 V84
interval 2015-10-08 13:20:00 2015-10-08 13:30:00 2015-10-08 13:40:00 2015-10-08 13:50:00
                         V85                 V86                 V87                 V88
interval 2015-10-08 14:00:00 2015-10-08 14:10:00 2015-10-08 14:20:00 2015-10-08 14:30:00
                         V89                 V90                 V91                 V92
interval 2015-10-08 14:40:00 2015-10-08 14:50:00 2015-10-08 15:00:00 2015-10-08 15:10:00
                         V93                 V94                 V95                 V96
interval 2015-10-08 15:20:00 2015-10-08 15:30:00 2015-10-08 15:40:00 2015-10-08 15:50:00
                         V97                 V98                 V99                V100
interval 2015-10-08 16:00:00 2015-10-08 16:10:00 2015-10-08 16:20:00 2015-10-08 16:30:00
                        V101                V102                V103                V104
interval 2015-10-08 16:40:00 2015-10-08 16:50:00 2015-10-08 17:00:00 2015-10-08 17:10:00
                        V105                V106                V107                V108
interval 2015-10-08 17:20:00 2015-10-08 17:30:00 2015-10-08 17:40:00 2015-10-08 17:50:00
                        V109                V110                V111                V112
interval 2015-10-08 18:00:00 2015-10-08 18:10:00 2015-10-08 18:20:00 2015-10-08 18:30:00
                        V113                V114                V115                V116
interval 2015-10-08 18:40:00 2015-10-08 18:50:00 2015-10-08 19:00:00 2015-10-08 19:10:00
                        V117                V118                V119                V120
interval 2015-10-08 19:20:00 2015-10-08 19:30:00 2015-10-08 19:40:00 2015-10-08 19:50:00
                        V121                V122                V123                V124
interval 2015-10-08 20:00:00 2015-10-08 20:10:00 2015-10-08 20:20:00 2015-10-08 20:30:00
                        V125                V126                V127                V128
interval 2015-10-08 20:40:00 2015-10-08 20:50:00 2015-10-08 21:00:00 2015-10-08 21:10:00
                        V129                V130                V131                V132
interval 2015-10-08 21:20:00 2015-10-08 21:30:00 2015-10-08 21:40:00 2015-10-08 21:50:00
                        V133                V134                V135                V136
interval 2015-10-08 22:00:00 2015-10-08 22:10:00 2015-10-08 22:20:00 2015-10-08 22:30:00
                        V137                V138                V139                V140
interval 2015-10-08 22:40:00 2015-10-08 22:50:00 2015-10-08 23:00:00 2015-10-08 23:10:00
                        V141                V142                V143                V144
interval 2015-10-08 23:20:00 2015-10-08 23:30:00 2015-10-08 23:40:00 2015-10-08 23:50:00

我试图使列名等于数据框的第一行,但是存在问题,因为第一行中的值是PosixCt格式。当我尝试将它们转换为字符时 - 就会发生这种情况:

as.character(incoming_matrix[1,])
  [1] "6"  "4"  "4"  "3"  "4"  "4"  "4"  "4"  "3"  "4"  "4"  "3"  "3"  "3"  "3"  "3"  "3"  "3"  "3"  "2"  "3"  "2" 
 [23] "3"  "2"  "2"  "3"  "3"  "2"  "3"  "3"  "3"  "3"  "3"  "4"  "4"  "4"  "5"  "6"  "5"  "6"  "7"  "8"  "9"  "9" 
 [45] "10" "9"  "12" "14" "13" "11" "14" "16" "16" "17" "16" "13" "14" "13" "13" "11" "10" "9"  "8"  "7"  "8"  "9" 
 [67] "6"  "6"  "7"  "7"  "6"  "9"  "7"  "7"  "8"  "8"  "9"  "8"  "8"  "8"  "8"  "8"  "7"  "9"  "9"  "7"  "9"  "10"
 [89] "7"  "10" "8"  "10" "8"  "9"  "8"  "9"  "9"  "10" "12" "11" "11" "12" "13" "14" "13" "12" "14" "15" "16" "12"
[111] "13" "13" "13" "12" "11" "11" "11" "11" "9"  "10" "8"  "8"  "8"  "7"  "9"  "9"  "9"  "7"  "6"  "8"  "7"  "8" 
[133] "8"  "6"  "7"  "7"  "7"  "5"  "5"  "6"  "6"  "5"  "5"  "5"

如何在第一行中的值之后命名我的colnames,而无需手动执行?

> dput(incoming_matrix[1,])
structure(list(`6` = structure(6L, .Label = c(" 1", " 2", " 3", 
" 4", " 5", "2015-10-08 00:00:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 00:10:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 00:20:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 00:30:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 00:40:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 00:50:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 01:00:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 01:10:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 01:20:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 01:30:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 01:40:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 01:50:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 02:00:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 02:10:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 02:20:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 02:30:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 02:40:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 02:50:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 03:00:00"), class = "factor"), `2` = structure(2L, .Label = c(" 1", 
"2015-10-08 03:10:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 03:20:00"), class = "factor"), `2` = structure(2L, .Label = c(" 1", 
"2015-10-08 03:30:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 03:40:00"), class = "factor"), `2` = structure(2L, .Label = c(" 1", 
"2015-10-08 03:50:00"), class = "factor"), `2` = structure(2L, .Label = c(" 1", 
"2015-10-08 04:00:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 04:10:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 3", "2015-10-08 04:20:00"), class = "factor"), `2` = structure(2L, .Label = c(" 1", 
"2015-10-08 04:30:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 04:40:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 04:50:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 3", "2015-10-08 05:00:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 05:10:00"), class = "factor"), `3` = structure(3L, .Label = c(" 1", 
" 2", "2015-10-08 05:20:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 05:30:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 05:40:00"), class = "factor"), `4` = structure(4L, .Label = c(" 1", 
" 2", " 3", "2015-10-08 05:50:00"), class = "factor"), `5` = structure(5L, .Label = c(" 1", 
" 2", " 3", " 4", "2015-10-08 06:00:00"), class = "factor"), 
    `6` = structure(6L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    "2015-10-08 06:10:00"), class = "factor"), `5` = structure(5L, .Label = c(" 1", 
    " 2", " 3", " 4", "2015-10-08 06:20:00"), class = "factor"), 
    `6` = structure(6L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    "2015-10-08 06:30:00"), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "2015-10-08 06:40:00"), class = "factor"), 
    `8` = structure(8L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 9", "2015-10-08 06:50:00"), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "13", "2015-10-08 07:00:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 7", " 8", "10", "2015-10-08 07:10:00"
    ), class = "factor"), `10` = structure(10L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "2015-10-08 07:20:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "11", "2015-10-08 07:30:00"
    ), class = "factor"), `12` = structure(12L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "11", "12", 
    "2015-10-08 07:40:00"), class = "factor"), `14` = structure(14L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "13", "2015-10-08 07:50:00"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "13", "2015-10-08 08:00:00"), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "2015-10-08 08:10:00"
    ), class = "factor"), `14` = structure(14L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "14", "2015-10-08 08:20:00"), class = "factor"), `16` = structure(16L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "13", "14", "18", "2015-10-08 08:30:00"), class = "factor"), 
    `16` = structure(16L, .Label = c(" 1", " 2", " 3", " 4", 
    " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "16", "17", 
    "18", "2015-10-08 08:40:00"), class = "factor"), `17` = structure(17L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "13", "14", "16", "17", "2015-10-08 08:50:00", "21", 
    "23"), class = "factor"), `16` = structure(16L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "13", "15", "17", "2015-10-08 09:00:00", "22"), class = "factor"), 
    `13` = structure(13L, .Label = c(" 1", " 2", " 3", " 4", 
    " 5", " 6", " 7", " 8", " 9", "10", "14", "16", "2015-10-08 09:10:00"
    ), class = "factor"), `14` = structure(14L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "17", "2015-10-08 09:20:00"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "14", "2015-10-08 09:30:00"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "10", "11", "13", 
    "15", "2015-10-08 09:40:00"), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "2015-10-08 09:50:00"
    ), class = "factor"), `10` = structure(10L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "12", "2015-10-08 10:00:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 9", "2015-10-08 10:10:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 10:20:00"
    ), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "2015-10-08 10:30:00"), class = "factor"), 
    `8` = structure(8L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", "2015-10-08 10:40:00"), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "2015-10-08 10:50:00"
    ), class = "factor"), `6` = structure(6L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", "2015-10-08 11:00:00"), class = "factor"), 
    `6` = structure(6L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    "2015-10-08 11:10:00"), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 8", "2015-10-08 11:20:00"), class = "factor"), 
    `7` = structure(7L, .Label = c(" 1", " 2", " 3", " 4", " 6", 
    " 7", "2015-10-08 11:30:00"), class = "factor"), `6` = structure(6L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", "2015-10-08 11:40:00"), class = "factor"), 
    `9` = structure(9L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", "11", "2015-10-08 11:50:00"), class = "factor"), 
    `7` = structure(7L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", "2015-10-08 12:00:00"), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "2015-10-08 12:10:00"), class = "factor"), 
    `8` = structure(8L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 9", "2015-10-08 12:20:00"), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "10", "2015-10-08 12:30:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 9", "2015-10-08 12:40:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 8", "2015-10-08 12:50:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 13:00:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 13:10:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 13:20:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "15", "2015-10-08 13:30:00"
    ), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "2015-10-08 13:40:00"), class = "factor"), 
    `9` = structure(9L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", " 8", "2015-10-08 13:50:00"), class = "factor"), 
    `9` = structure(9L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", "17", "2015-10-08 14:00:00"), class = "factor"), 
    `7` = structure(7L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", "2015-10-08 14:10:00"), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 8", "10", "2015-10-08 14:20:00"
    ), class = "factor"), `10` = structure(10L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "10", "2015-10-08 14:30:00"
    ), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "2015-10-08 14:40:00"), class = "factor"), 
    `10` = structure(10L, .Label = c(" 1", " 2", " 3", " 4", 
    " 5", " 6", " 7", " 8", " 9", "2015-10-08 14:50:00"), class = "factor"), 
    `8` = structure(8L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 8", "2015-10-08 15:00:00"), class = "factor"), `10` = structure(10L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "11", "2015-10-08 15:10:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 15:20:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 9", "2015-10-08 15:30:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 15:40:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 8", " 9", "2015-10-08 15:50:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "2015-10-08 16:00:00"
    ), class = "factor"), `10` = structure(10L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "11", "2015-10-08 16:10:00"
    ), class = "factor"), `12` = structure(12L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "17", 
    "2015-10-08 16:20:00"), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "10", "12", "2015-10-08 16:30:00"
    ), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "14", "2015-10-08 16:40:00"
    ), class = "factor"), `12` = structure(12L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "11", "14", 
    "2015-10-08 16:50:00"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "2015-10-08 17:00:00"), class = "factor"), `14` = structure(14L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "14", "2015-10-08 17:10:00", "21"), class = "factor"), 
    `13` = structure(13L, .Label = c(" 1", " 2", " 3", " 4", 
    " 5", " 6", " 7", " 8", " 9", "11", "12", "14", "2015-10-08 17:20:00", 
    "32"), class = "factor"), `12` = structure(12L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "13", 
    "2015-10-08 17:30:00", "27"), class = "factor"), `14` = structure(14L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "12", 
    "14", "15", "2015-10-08 17:40:00", "27"), class = "factor"), 
    `15` = structure(15L, .Label = c(" 1", " 2", " 3", " 4", 
    " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "14", "16", 
    "2015-10-08 17:50:00"), class = "factor"), `16` = structure(16L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "12", 
    "14", "15", "19", "20", "2015-10-08 18:00:00"), class = "factor"), 
    `12` = structure(12L, .Label = c(" 1", " 2", " 3", " 4", 
    " 5", " 6", " 7", " 8", " 9", "10", "17", "2015-10-08 18:10:00", 
    "23"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "14", "2015-10-08 18:20:00"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", 
    "12", "2015-10-08 18:30:00"), class = "factor"), `13` = structure(13L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "11", "12", 
    "13", "2015-10-08 18:40:00"), class = "factor"), `12` = structure(12L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "10", "11", "14", 
    "2015-10-08 18:50:00"), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "10", "11", "2015-10-08 19:00:00"
    ), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "2015-10-08 19:10:00"
    ), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "11", "2015-10-08 19:20:00"
    ), class = "factor"), `11` = structure(11L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "10", "15", "2015-10-08 19:30:00"
    ), class = "factor"), `9` = structure(9L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 8", " 9", "2015-10-08 19:40:00"
    ), class = "factor"), `10` = structure(10L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", " 8", "11", "2015-10-08 19:50:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 20:00:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 20:10:00"
    ), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 20:20:00"
    ), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", "12", "2015-10-08 20:30:00"), class = "factor"), 
    `9` = structure(9L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", " 8", "2015-10-08 20:40:00"), class = "factor"), 
    `9` = structure(9L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", "10", "2015-10-08 20:50:00"), class = "factor"), 
    `9` = structure(9L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 7", " 9", "2015-10-08 21:00:00"), class = "factor"), 
    `7` = structure(7L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", "2015-10-08 21:10:00"), class = "factor"), `6` = structure(6L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", "2015-10-08 21:20:00"), class = "factor"), 
    `8` = structure(8L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", " 9", "2015-10-08 21:30:00"), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 7", "2015-10-08 21:40:00"), class = "factor"), 
    `8` = structure(8L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 7", " 8", "2015-10-08 21:50:00"), class = "factor"), `8` = structure(8L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", " 7", "2015-10-08 22:00:00"
    ), class = "factor"), `6` = structure(6L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", "2015-10-08 22:10:00"), class = "factor"), 
    `7` = structure(7L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    " 6", "2015-10-08 22:20:00"), class = "factor"), `7` = structure(7L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", " 6", "2015-10-08 22:30:00"), class = "factor"), 
    `7` = structure(7L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    "11", "2015-10-08 22:40:00"), class = "factor"), `5` = structure(5L, .Label = c(" 1", 
    " 2", " 3", " 4", "2015-10-08 22:50:00"), class = "factor"), 
    `5` = structure(5L, .Label = c(" 1", " 2", " 3", " 4", "2015-10-08 23:00:00"
    ), class = "factor"), `6` = structure(6L, .Label = c(" 1", 
    " 2", " 3", " 4", " 5", "2015-10-08 23:10:00"), class = "factor"), 
    `6` = structure(6L, .Label = c(" 1", " 2", " 3", " 4", " 5", 
    "2015-10-08 23:20:00"), class = "factor"), `5` = structure(5L, .Label = c(" 1", 
    " 2", " 3", " 6", "2015-10-08 23:30:00"), class = "factor"), 
    `5` = structure(5L, .Label = c(" 1", " 2", " 3", " 4", "2015-10-08 23:40:00"
    ), class = "factor"), `5` = structure(5L, .Label = c(" 1", 
    " 2", " 3", " 4", "2015-10-08 23:50:00"), class = "factor")), .Names = c("6", 
"4", "4", "3", "4", "4", "4", "4", "3", "4", "4", "3", "3", "3", 
"3", "3", "3", "3", "3", "2", "3", "2", "3", "2", "2", "3", "3", 
"2", "3", "3", "3", "3", "3", "4", "4", "4", "5", "6", "5", "6", 
"7", "8", "9", "9", "10", "9", "12", "14", "13", "11", "14", 
"16", "16", "17", "16", "13", "14", "13", "13", "11", "10", "9", 
"8", "7", "8", "9", "6", "6", "7", "7", "6", "9", "7", "7", "8", 
"8", "9", "8", "8", "8", "8", "8", "7", "9", "9", "7", "9", "10", 
"7", "10", "8", "10", "8", "9", "8", "9", "9", "10", "12", "11", 
"11", "12", "13", "14", "13", "12", "14", "15", "16", "12", "13", 
"13", "13", "12", "11", "11", "11", "11", "9", "10", "8", "8", 
"8", "7", "9", "9", "9", "7", "6", "8", "7", "8", "8", "6", "7", 
"7", "7", "5", "5", "6", "6", "5", "5", "5"), row.names = "interval", class = "data.frame")

1 个答案:

答案 0 :(得分:3)

使用unlist删除列表结构:

names(incoming_matrix) <-  unlist(incoming_matrix[1,])