Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind_rows mangles yearmon data #13

Closed
ConorIA opened this issue Nov 27, 2016 · 1 comment
Closed

bind_rows mangles yearmon data #13

ConorIA opened this issue Nov 27, 2016 · 1 comment
Labels

Comments

@ConorIA
Copy link
Contributor

ConorIA commented Nov 27, 2016

This bug is probably on the dplyr side, but I figured I would bring it to your attention anyway. The bind_rows command contained in collapse_hcd chews up the yearmon data in the Date column for monthly data:

> l <- read_hcd(f)
> l
# A tibble: 192 × 12
            Date MaxTemp MinTemp MeanTemp ExtremeHigh ExtremeLow TotalRain TotalSnow TotalPrecip
   <S3: yearmon>   <dbl>   <dbl>    <dbl>       <dbl>      <dbl>     <dbl>     <dbl>       <dbl>
1       Jan 1956      NA      NA       NA          NA         NA        NA        NA          NA
2       Feb 1956      NA      NA       NA          NA         NA        NA        NA          NA
3       Mar 1956      NA      NA       NA          NA         NA        NA        NA          NA
4       Apr 1956      NA      NA       NA          NA         NA      84.6       2.8        87.4
5       May 1956      NA      NA       NA          NA         NA     115.3       0.0       115.3
6       Jun 1956      NA      NA       NA          NA         NA      37.3       0.0        37.3
7       Jul 1956      NA      NA       NA          NA         NA      77.0       0.0        77.0
8       Aug 1956      NA      NA       NA          NA         NA     221.5       0.0       221.5
9       Sep 1956      NA      NA       NA          NA         NA      55.4       0.0        55.4
10      Oct 1956      NA      NA       NA          NA         NA      29.7       0.0        29.7
# ... with 182 more rows, and 3 more variables: LastSnowGrnd <int>, MaxGustDir <int>,
#   MaxGustSpeed <chr>
> l <- bind_rows(l)
> l
# A tibble: 192 × 12
       Date MaxTemp MinTemp MeanTemp ExtremeHigh ExtremeLow TotalRain TotalSnow TotalPrecip
      <dbl>   <dbl>   <dbl>    <dbl>       <dbl>      <dbl>     <dbl>     <dbl>       <dbl>
1  1956.000      NA      NA       NA          NA         NA        NA        NA          NA
2  1956.083      NA      NA       NA          NA         NA        NA        NA          NA
3  1956.167      NA      NA       NA          NA         NA        NA        NA          NA
4  1956.250      NA      NA       NA          NA         NA      84.6       2.8        87.4
5  1956.333      NA      NA       NA          NA         NA     115.3       0.0       115.3
6  1956.417      NA      NA       NA          NA         NA      37.3       0.0        37.3
7  1956.500      NA      NA       NA          NA         NA      77.0       0.0        77.0
8  1956.583      NA      NA       NA          NA         NA     221.5       0.0       221.5
9  1956.667      NA      NA       NA          NA         NA      55.4       0.0        55.4
10 1956.750      NA      NA       NA          NA         NA      29.7       0.0        29.7
# ... with 182 more rows, and 3 more variables: LastSnowGrnd <int>, MaxGustDir <int>,
#   MaxGustSpeed <chr>

We can put it back to normal by re-running l$Date <- as.yearmon(l$Date). Fix recommended in #14.

@gavinsimpson
Copy link
Owner

Thanks for reporting this @ConorIA. It seems it is a missing "feature" in bind_rows() (I'd call this a bug, but...). I've added a comment to an existing open bug on dplyr tidyverse/dplyr#1829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants