etiennebacher / tidypolars

Get the power of polars with the syntax of the tidyverse
https://tidypolars.etiennebacher.com
Other
179 stars 4 forks source link

Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "RPolarsDataFrame" #70

Closed Biomiha closed 11 months ago

Biomiha commented 11 months ago

Hi,

I have just downloaded the package and when trying the example code I can't seem to dispatch any dplyr methods on the RPolarsDataFrame object.

library(dplyr, warn.conflicts = FALSE)

iris |> 
  select(starts_with(c("Sep", "Pet"))) |> 
  mutate(
    petal_type = ifelse((Petal.Length / Petal.Width) > 3, "long", "large")
  ) |> 
  filter(between(Sepal.Length, 4.5, 5.5)) |> 
  head()

library(tidypolars)
#> Registered S3 method overwritten by 'tidypolars':
#>   method          from  
#>   print.DataFrame polars

iris |> 
  as_polars() |> 
  select(starts_with(c("Sep", "Pet"))) |> 
  mutate(
    petal_type = ifelse((Petal.Length / Petal.Width) > 3, "long", "large")
  ) |> 
  filter(between(Sepal.Length, 4.5, 5.5)) |> 
  head()

I get the following error:

  Error in UseMethod("select") : 
      no applicable method for 'select' applied to an object of class "RPolarsDataFrame"

I've tried googling and have gone through the other github issues but it seems no one has so far had a similar problem (or at least I can't find it). I am on an Intel architecture MacBook Pro and have the most recent R4.3.2 version installed.

Any ideas what I am doing wrong? Thanks

etiennebacher commented 11 months ago

Hello, in the development version of polars, we have changed class names from e.g DataFrame to RPolarsDataFrame. This has an impact on tidypolars because I use the class name to dispatch the S3 method. I think you're using the development version of polars (0.11.0.9000).

I have opened #67 and will merge it once polars 0.12.0 is released. In the meantime, the easiest solution is to install polars 0.11.0 from R-universe using one of the two commands here (depending on your OS): https://rpolars.github.io/#r-universe-recommended

Let me know if this works

Biomiha commented 11 months ago

Hi,

It worked once I compiled polars from source. All fine now.

Thanks