Let's suppose in this given dataframe, you want to write a filter that returns a subset for date_visit>2020-02-15, it should return 2 rows only.
If you want to do the filtering with R but inside Power BI this is how you will do it
# 'dataset' holds the input data for this script
dataset$date_visit<-as.Date(dataset$date_visit)
dataset$date_order<-as.Date(dataset$date_order)
filter<-subset(dataset,date_visit>"2020-02-15")
filter
The full M is here
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY8xCoAwEAT/ktpAbnNRnyHYJIQUFoKVFvp/PAhJFMTqmGKY2xgVseuHYVSdgoHRhrRBBSssMG/Hesr1nlTq/h0SYIFp2a/s4NNxmlqn18Crkx1YdkT06KA5yNHihPDtyARbgfOe8lsIsifd", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustomerID = _t, date_visit = _t, date_order = _t, ProductType = _t, DeviceNumber = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerID", Int64.Type}, {"date_visit", type text}, {"date_order", type text}, {"ProductType", type text}, {"DeviceNumber", type text}}),
#"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)src<-data.frame(dataset)#(lf)dataset$date_visit<-as.Date(dataset$date_visit)#(lf)dataset$date_order<-as.Date(dataset$date_order)#(lf)filter<-subset(dataset,date_visit>""2020-02-15"")#(lf)filter",[dataset=#"Changed Type"]),
filter = #"Run R script"{[Name="filter"]}[Value]
in
filter

If you want to pass on a parameterized value (generated through some dynamic M query / Parameter created by you / hardcoded value) for date_visit you need to pass on like following
let
val ="2020-02-15", /*this is the parameterized value either dynamically generated or harcoded to be passed on to R */
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY8xCoAwEAT/ktpAbnNRnyHYJIQUFoKVFvp/PAhJFMTqmGKY2xgVseuHYVSdgoHRhrRBBSssMG/Hesr1nlTq/h0SYIFp2a/s4NNxmlqn18Crkx1YdkT06KA5yNHihPDtyARbgfOe8lsIsifd", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustomerID = _t, date_visit = _t, date_order = _t, ProductType = _t, DeviceNumber = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerID", Int64.Type}, {"date_visit", type text}, {"date_order", type text}, {"ProductType", type text}, {"DeviceNumber", type text}}),
#"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)src<-data.frame(dataset)#(lf)src$date_visit<-as.Date(src$date_visit)#(lf)src$date_order<-as.Date(src$date_order)#(lf)filter<-subset(src,date_visit>"""&val&""")#(lf)filter",[dataset=#"Changed Type"]),
filter = #"Run R script"{[Name="filter"]}[Value]
in
filter
It generates following

If you are dynamically filtering dataframes like this in PBI, one aspect to keep in mind that, dataType Date are extremely tricky between R and and PBI. It must be converted with as.Date first before any filtering can be applied on the R side.
But if you were filtering on ProductType="Shoes", you can could have simply done this
let
val ="Shoes",
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY8xCoAwEAT/ktpAbnNRnyHYJIQUFoKVFvp/PAhJFMTqmGKY2xgVseuHYVSdgoHRhrRBBSssMG/Hesr1nlTq/h0SYIFp2a/s4NNxmlqn18Crkx1YdkT06KA5yNHihPDtyARbgfOe8lsIsifd", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustomerID = _t, date_visit = _t, date_order = _t, ProductType = _t, DeviceNumber = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerID", Int64.Type}, {"date_visit", type text}, {"date_order", type text}, {"ProductType", type text}, {"DeviceNumber", type text}}),
#"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)src<-dataset#(lf)filter<-subset(src, ProductType=="""&val&""")",[dataset=#"Changed Type"]),
filter = #"Run R script"{[Name="filter"]}[Value]
in
filter