etiennebacher / tidypolars

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

Selecting from column names #123

Closed mohunter closed 1 day ago

mohunter commented 6 days ago

Bug description Unable to select from column names

To Reproduce

library(polars)
library(tidypolars)
library(dplyr, warn.conflicts = FALSE)
test = pl$DataFrame("med_ht" = 1:5, "rowid" = 1:5,"green_glad.SeasConv.ard2_m_30m_s_0701_0831_go_epsg.4326_v20230908" = 1:5, "green_glad.SeasConv.ard2_m_30m_s_0301_0430_go_epsg.4326_v20230908" = 1:5, "glad_ndvi_0701" = 1:5)
test |>  
     select(contains("0701")) 

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘select’ for signature ‘"RPolarsDataFrame"’

I expect the code to select the two columns including 0701 in the column name, "green_glad.SeasConv.ard2_m_30m_s_0701_0831_go_epsg.4326_v20230908" and "glad_ndvi_0701"

As a note-- I was able to get the selection working with regex in the polars package by selecting on "^0701.$" -- without the period it pulls only "glad_ndvi_0701" for me.

etiennebacher commented 6 days ago

I can't reproduce, can you try with the github version of tidypolars and in a clean R session? The ideal would be to use reprex

library(polars)
library(tidypolars)
library(dplyr, warn.conflicts = FALSE)
test = pl$DataFrame("med_ht" = 1:5, "rowid" = 1:5,"green_glad.SeasConv.ard2_m_30m_s_0701_0831_go_epsg.4326_v20230908" = 1:5, "green_glad.SeasConv.ard2_m_30m_s_0301_0430_go_epsg.4326_v20230908" = 1:5, "glad_ndvi_0701" = 1:5)
test |>  
  select(contains("0701"))
#> shape: (5, 2)
#> ┌─────────────────────────────────┬────────────────┐
#> │ green_glad.SeasConv.ard2_m_30m… ┆ glad_ndvi_0701 │
#> │ ---                             ┆ ---            │
#> │ i32                             ┆ i32            │
#> ╞═════════════════════════════════╪════════════════╡
#> │ 1                               ┆ 1              │
#> │ 2                               ┆ 2              │
#> │ 3                               ┆ 3              │
#> │ 4                               ┆ 4              │
#> │ 5                               ┆ 5              │
#> └─────────────────────────────────┴────────────────┘
etiennebacher commented 1 day ago

@mohunter I'm closing this to clean the issue tracker but please feel free to reopen if this bug still happens.

mohunter commented 13 hours ago

Thanks etienne --

I found the issue, for me I had to specify dplyr::select and then all worked smoothly. Sorry for the confusion and thank you for pointing me to tidypolars.

Maria

On Mon, Jul 1, 2024 at 3:44 AM Etienne Bacher @.***> wrote:

@mohunter https://github.com/mohunter I'm closing this to clean the issue tracker but please feel free to reopen if this bug still happens.

— Reply to this email directly, view it on GitHub https://github.com/etiennebacher/tidypolars/issues/123#issuecomment-2199462141, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHFLFJ7RJI6WXCC2SL6G5LDZKECE7AVCNFSM6AAAAABJ6CRJMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJZGQ3DEMJUGE . You are receiving this because you were mentioned.Message ID: @.***>