Skip to content

partial() fails with S3 generics on older R versions #647

@ColinFay

Description

@ColinFay

I bet this will have the same roots as #629 & #639, but as these two only present compose, I just wanted to share that partial fails with S3 generics:

library(purrr)
packageVersion("purrr")
#> [1] '0.3.0'

map(airquality, mean)
#> $Ozone
#> [1] NA
#> 
#> $Solar.R
#> [1] NA
#> 
#> $Wind
#> [1] 9.957516
#> 
#> $Temp
#> [1] 77.88235
#> 
#> $Month
#> [1] 6.993464
#> 
#> $Day
#> [1] 15.80392

p_mean <- partial(mean, na.rm = TRUE)
p_mean
#> <partialised>
#> function (...) 
#> mean(na.rm = TRUE, ...)
map(airquality, p_mean)
#> Error in UseMethod("mean"): no applicable method for 'mean' applied to an object of class "c('integer', 'numeric')"

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions