Giter Site home page Giter Site logo

Comments (3)

karldw avatar karldw commented on June 11, 2024

Lists of functions seem to have the same problem, and I get the same error for all of the summarize_*, mutate_*, and transmute_* functions.

library(tidyverse)

fn_list <- list(
  p=function(x) x/2,
  q=function(x) x/4
)
df <- dbplyr::memdb_frame(a=1, b=2) 

df %>%
  collect() %>% 
  transmute_at(vars(a,b), .funs=fn_list)
#> A tibble: 1 x 4
#>    a_p   b_p   a_q   b_q
#>  <dbl> <dbl> <dbl> <dbl>
#> 1  0.5     1  0.25   0.5

df %>% transmute_at(vars(a,b), .funs=fn_list)
#> Error in (function (x)  : object 'a' not found

from dbplyr.

hadley avatar hadley commented on June 11, 2024

Mild reprex tweaking

library(dplyr, warn.conflicts = FALSE)
mf <- dbplyr::memdb_frame(a = 1, b = 2)

# WORKS
mf %>% summarize_all(mean, na.rm = TRUE)
#> # Source:   lazy query [?? x 2]
#> # Database: sqlite 3.22.0 [:memory:]
#>       a     b
#>   <dbl> <dbl>
#> 1     1     2

# FAILS
mf %>% summarize_all(~mean(.))
#> Error in mean(.): object 'a' not found
mf %>% summarize_all(list(mean))
#> Error in (function (x, ...) : object 'a' not found

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

from dbplyr.

hadley avatar hadley commented on June 11, 2024

summarise_all() creates a list of inlined functions so an even more focussed reprex is this:

library(dbplyr)

partial_eval(rlang::expr(mean(x)), vars = "x")
#> mean(x)
partial_eval(rlang::expr((!!mean)(x)), vars = "x")
#> Error in (function (x, ...) : object 'x' not found

Created on 2019-02-06 by the reprex package (v0.2.1.9000)

from dbplyr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.