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

meteo_nearby_stations() fails when working with tibbles (as opposed to data frames) #340

Closed
taraskaduk opened this issue Dec 27, 2019 · 2 comments
Labels
Milestone

Comments

@taraskaduk
Copy link

taraskaduk commented Dec 27, 2019

Hello there!
I found that meteo_nearby_stations() doesn't seem to deal with tibbles very well, as opposed to data frames. It returns NAs for distance, and if no limit is specified - it returns all available stations.

It is not a problem to convert to a data frame from tibble. It is a problem, however, to diagnose the issue if you don't know what to look for.

Reprex
library(rnoaa)
library(tidyverse)

dataframe <- data.frame(id = c("sydney", "brisbane"),
                        latitude = c(-33.8675, -27.4710),
                        longitude = c(151.2070, 153.0234))
dataframe_stations <- meteo_nearby_stations(dataframe, radius = 10)
dataframe_stations
#> $brisbane
#> # A tibble: 58 x 5
#>    id          name                       latitude longitude distance
#>    <chr>       <chr>                         <dbl>     <dbl>    <dbl>
#>  1 ASN00040839 BRISBANE (BCC) ALERT          -27.5      153.    0.507
#>  2 ASN00040367 ST LUCIA TRAINING FARM        -27.5      153.    0.816
#>  3 ASN00040214 BRISBANE REGIONAL OFFICE      -27.5      153.    1.04 
#>  4 ASN00040359 HIGHGATE HILL                 -27.5      153.    1.52 
#>  5 ASN00040900 NORMANBY RAIL YARD            -27.5      153.    1.61 
#>  6 ASN00040215 BRISBANE BOTANICAL GARDENS    -27.5      153.    1.68 
#>  7 ASN00040911 HILLTOP GARDENS               -27.5      153.    1.86 
#>  8 ASN00040913 BRISBANE                      -27.5      153.    1.88 
#>  9 ASN00040233 MILTON                        -27.5      153     2.36 
#> 10 ASN00040216 BRISBANE SHOW GROUNDS         -27.5      153.    2.47 
#> # … with 48 more rows
#> 
#> $sydney
#> # A tibble: 62 x 5
#>    id          name                          latitude longitude distance
#>    <chr>       <chr>                            <dbl>     <dbl>    <dbl>
#>  1 ASN00066062 SYDNEY (OBSERVATORY HILL)        -33.9      151.    0.778
#>  2 ASN00066006 SYDNEY BOTANIC GARDENS           -33.9      151.    0.843
#>  3 ASN00066015 CROWN ST. RESERVOIR              -33.9      151.    1.87 
#>  4 ASN00066139 PADDINGTON                       -33.9      151.    1.97 
#>  5 ASN00066149 GLEBE POINT SYD. WATER SUPPLY    -33.9      151.    2.19 
#>  6 ASN00066178 BIRCHGROVE SCHOOL                -33.8      151.    2.93 
#>  7 ASN00066075 WAVERTON BOWLING CLUB            -33.8      151.    3.09 
#>  8 ASN00066097 RANWICK BUNNERONG RD             -33.9      151.    3.67 
#>  9 ASN00066033 ALEXANDRIA (HENDERSON ROAD)      -33.9      151.    3.74 
#> 10 ASN00066061 SYDNEY NTH BOWLING CLUB          -33.8      151.    3.86 
#> # … with 52 more rows


tibble <- tibble(id = c("sydney", "brisbane"),
                 latitude = c(-33.8675, -27.4710),
                 longitude = c(151.2070, 153.0234))
tibble_stations <- meteo_nearby_stations(tibble, radius = 10)
#> Warning in meteo_nearby_stations(tibble, radius = 10): NAs introduced by
#> coercion

#> Warning in meteo_nearby_stations(tibble, radius = 10): NAs introduced by
#> coercion
tibble_stations
#> $brisbane
#> # A tibble: 115,072 x 5
#>    id    name  latitude longitude distance
#>    <chr> <chr>    <dbl>     <dbl>    <dbl>
#>  1 <NA>  <NA>        NA        NA       NA
#>  2 <NA>  <NA>        NA        NA       NA
#>  3 <NA>  <NA>        NA        NA       NA
#>  4 <NA>  <NA>        NA        NA       NA
#>  5 <NA>  <NA>        NA        NA       NA
#>  6 <NA>  <NA>        NA        NA       NA
#>  7 <NA>  <NA>        NA        NA       NA
#>  8 <NA>  <NA>        NA        NA       NA
#>  9 <NA>  <NA>        NA        NA       NA
#> 10 <NA>  <NA>        NA        NA       NA
#> # … with 115,062 more rows
#> 
#> $sydney
#> # A tibble: 115,072 x 5
#>    id    name  latitude longitude distance
#>    <chr> <chr>    <dbl>     <dbl>    <dbl>
#>  1 <NA>  <NA>        NA        NA       NA
#>  2 <NA>  <NA>        NA        NA       NA
#>  3 <NA>  <NA>        NA        NA       NA
#>  4 <NA>  <NA>        NA        NA       NA
#>  5 <NA>  <NA>        NA        NA       NA
#>  6 <NA>  <NA>        NA        NA       NA
#>  7 <NA>  <NA>        NA        NA       NA
#>  8 <NA>  <NA>        NA        NA       NA
#>  9 <NA>  <NA>        NA        NA       NA
#> 10 <NA>  <NA>        NA        NA       NA
#> # … with 115,062 more rows

Created on 2019-12-27 by the reprex package (v0.3.0)

@sckott
Copy link
Contributor

sckott commented Dec 30, 2019

thanks for the report @taraskaduk

having a look

@sckott sckott added the bug label Dec 30, 2019
@sckott sckott added this to the v0.9.6 milestone Dec 30, 2019
@sckott sckott closed this as completed in 1d84dd1 Dec 30, 2019
@sckott
Copy link
Contributor

sckott commented Dec 30, 2019

should be fixed now. i am just coercing the tibble or data.frame to a data.frame as the first step internally, so we are always dealing with a data.frame

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