dplyr full_join没有按预期工作,有2个同名列

时间:2018-03-26 11:36:19

标签: r dplyr tidyverse

我有以下两个小节:

pc.tbl

<div id="box">
  <div id="boxa">A</div>
  <div id="boxb">B</div>
  <div id="boxc">C</div>
  <div id="boxd">D</div>
</div>

nt

  Date       status_is `Consumption  France`
  <date>     <chr>                     <dbl>
1 2018-03-21 Forecast                  -1364
2 2018-03-22 Forecast                  -1368
3 2018-03-23 Forecast                  -1294
4 2018-03-24 Forecast                  -1050
5 2018-03-25 Forecast                  -1036
6 2018-03-26 Forecast                  -1223

当我使用完全加入时:

  Date       `Seasonal Normal Temperature` geography_is status_is `Consumption Residential France` `TIGF Consumption` `Consumption Industrial France`
  <date>                             <dbl> <chr>        <chr>                                <dbl>              <dbl>                           <dbl>
1 2018-04-09                          9.93 France       Normal                                1070               96.0                             427
2 2018-04-10                         10.0  France       Normal                                1060               95.0                             426
3 2018-04-11                         10.1  France       Normal                                1050               94.0                             425
4 2018-04-12                         10.2  France       Normal                                1040               94.0                             424
5 2018-04-13                         10.4  France       Normal                                1030               93.0                             423
6 2018-04-14                         10.5  France       Normal                                 910               82.0                             393

我明白了:

p = full_join(pc.tbl, nt), by = "Date")

显然我不希望将列status_is拆分为2.如果查看列的类型,它们都是字符。我还检查了名称是否相等,它们是:

   Date       status_is.x `Consumption  France` `Seasonal Normal Temperature` geography_is status_is.y `Consumption Residential France` `TIGF Consumption` `Consumption Industr~
   <date>     <chr>                       <dbl>                         <dbl> <chr>        <chr>                                  <dbl>              <dbl>                 <dbl>
 1 2018-03-21 Forecast                    -1364                         NA    NA           NA                                        NA               NA                      NA
 2 2018-03-22 Forecast                    -1368                         NA    NA           NA                                        NA               NA                      NA
 3 2018-03-23 Forecast                    -1294                         NA    NA           NA                                        NA               NA                      NA
 4 2018-03-24 Forecast                    -1050                         NA    NA           NA                                        NA               NA                      NA
 5 2018-03-25 Forecast                    -1036                         NA    NA           NA                                        NA               NA                      NA
 6 2018-03-26 Forecast                    -1223                         NA    NA           NA                                        NA               NA                      NA
 7 2018-03-27 Forecast                    -1142                         NA    NA           NA                                        NA               NA                      NA
 8 2018-04-09 NA                             NA                          9.93 France       Normal                                  1070               96.0                   427
 9 2018-04-10 NA                             NA                         10.0  France       Normal                                  1060               95.0                   426
10 2018-04-11 NA                             NA                         10.1  France       Normal                                  1050               94.0                   425

我真的很难过这里

0 个答案:

没有答案