I prefer the tidyverse code that others have proposed, but if you want a raw R solution, the keyword "subset" will do the job and will work just as well in a function:
#Create a subset of a data.frame or data.table
subData <- subset(OriginalData, group == "a")
If you wish to make your own then I suggest this function:
makeSub <- function(data, groupVariable, value) {
return(subset(data, data[groupVariable,] == value))
}
In the function above, groupVariable = the number of the column you wish to use for subsetting.
You had no return statement in your function, BTW,
Rather than making a subSetting function, why not just use the built-in "subset" function? It's just as easy.