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

Add join example to vignette #120

Closed
boshek opened this issue Feb 2, 2019 · 0 comments
Closed

Add join example to vignette #120

boshek opened this issue Feb 2, 2019 · 0 comments
Assignees

Comments

@boshek
Copy link
Collaborator

boshek commented Feb 2, 2019

A la:

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tidyr)
library(ggplot2)

stns <- c("08NH130", "08NH005")
dly_data <- hy_daily_flows(station_number = stns) %>%
  left_join(
    hy_stations(station_number = stns) %>%
      select(STATION_NUMBER, DRAINAGE_AREA_GROSS),
    by = "STATION_NUMBER") %>%
  mutate(RO = Value / DRAINAGE_AREA_GROSS * 86400 / 1e6 * 1e3)
#> Error in hy_daily_flows(station_number = stns): could not find function "hy_daily_flows"

data <- dly_data %>% select(STATION_NUMBER, Date, RO) %>% spread(STATION_NUMBER, RO)
#> Error in eval(lhs, parent, parent): object 'dly_data' not found
colnames(data) <- c("Date", "Kaslo", "Fry")
#> Error in `colnames<-`(`*tmp*`, value = c("Date", "Kaslo", "Fry")): attempt to set 'colnames' on an object with less than two dimensions
ggplot(data) + 
  geom_point(aes(Kaslo , Fry))+
  labs(x = "Mean daily runoff - Kaslo [mm/d]",
       y = "Mean daily runoff - Fry [mm/d]")
#> Error: You're passing a function as global data.
#> Have you misspelled the `data` argument in `ggplot()`

Created on 2019-02-01 by the reprex package (v0.2.1)

It also might be interesting to contrast some SQL code which does this same thing and compare speeds.

@boshek boshek self-assigned this Feb 2, 2019
@boshek boshek added this to the tidyhydat 0.4.0 milestone Feb 2, 2019
@boshek boshek closed this as completed in 931c0b7 Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant