Skip to content

Commit

Permalink
Tweak example run times
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jun 15, 2015
1 parent ed6c336 commit 094b601
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions R/compute-collect.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
#' if (require("RSQLite") && has_lahman("sqlite")) {
#' batting <- tbl(lahman_sqlite(), "Batting")
#' remote <- select(filter(batting, yearID > 2010 && stint == 1), playerID:H)
#' \donttest{
#' remote2 <- collapse(remote)
#' cached <- compute(remote)
#' local <- collect(remote)
#' }
#' }
compute <- function(x, name = random_table_name(), ...) {
UseMethod("compute")
}
Expand Down
8 changes: 5 additions & 3 deletions R/tbl-df.r
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
#' rank(desc(AB)), cumsum(AB))
#'
#' # When you group by multiple level, each summarise peels off one level
#' \donttest{
#' per_year <- group_by(batting, playerID, yearID)
#' stints <- summarise(per_year, stints = max(stint))
#' # filter(stints, stints > 3)
#' # summarise(stints, max(stints))
#' # mutate(stints, cumsum(stints))
#' filter(stints, stints > 3)
#' summarise(stints, max(stints))
#' mutate(stints, cumsum(stints))
#' }
#'
#' # Joins ---------------------------------------------------------------------
#' player_info <- select(tbl_df(Master), playerID, birthYear)
Expand Down
2 changes: 2 additions & 0 deletions man/compute.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ it.
if (require("RSQLite") && has_lahman("sqlite")) {
batting <- tbl(lahman_sqlite(), "Batting")
remote <- select(filter(batting, yearID > 2010 && stint == 1), playerID:H)
\donttest{
remote2 <- collapse(remote)
cached <- compute(remote)
local <- collect(remote)
}
}
}
\seealso{
\code{\link{copy_to}} which is the conceptual opposite: it
takes a local data frame and makes it available to the remote source.
Expand Down
8 changes: 5 additions & 3 deletions man/tbl_df.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ progress <- mutate(players, cyear = yearID - min(yearID) + 1,
rank(desc(AB)), cumsum(AB))

# When you group by multiple level, each summarise peels off one level
\donttest{
per_year <- group_by(batting, playerID, yearID)
stints <- summarise(per_year, stints = max(stint))
# filter(stints, stints > 3)
# summarise(stints, max(stints))
# mutate(stints, cumsum(stints))
filter(stints, stints > 3)
summarise(stints, max(stints))
mutate(stints, cumsum(stints))
}

# Joins ---------------------------------------------------------------------
player_info <- select(tbl_df(Master), playerID, birthYear)
Expand Down

0 comments on commit 094b601

Please sign in to comment.