I have an example data frame named
df
Store Cash Only
1 "A" Y
2 "B" N
3 "C" N
4 "D" Y
Y
Cash Only
Store Cash Only
1 "A" Y
2 "D" Y
you just need to write a function that returns a subset of the input dataframe where cash == "Y"
:
df = data.frame(store=c("a","b","c","d"), cash=c("Y","N","N","Y"))
cash_only <- function(df){
return(subset(df, cash == "Y"))
}
new_df <- cash_only(df)