Hi
I am new to R and please let me know how to use across in filter function
my code is below
df1 <-read_sas(read_path(a_in,"adsl.sas7bdat"))
df2 <- filter(df1,across((ITTFL == "Y")))
ITTFL is row and values are Y , N and missing
I am gettting below error
df2 <- filter(df1,across((ITTFL == "Y")))
Error in filter():
! Problem while computing ..1 = across((ITTFL == "Y")).
Caused by error in across():
! object 'ITTFL' not found
But below code is working df2 <- filter(df2,(ITTFL == "Y")) , but what is use of across function
across function is used (typically in mutate/summarise) where you want to repeat the same operation across several variables. It has no use anywhere if you want to do one operation with one variable like to see if ITTFL equals Y
Using `across()` in `filter()` was deprecated in dplyr 1.0.8.
ℹ Please use `if_any()` or `if_all()` instead.
do you have an actual issue involving applying a multicolumn filter(s) for your work ?
if you want help with that. you can provide a reprex, otherwise the documentation includes examples of filters composed of multiple columns. e.g.
the first will filter to keep any row in which a column ending with Width in the name has a value greater than 4 , and the second will filter to keep any row where all columns ending Width in their name have values greater than 2