Earlier quoted context omitted.
Can you show an example of how to use R to read tabular data on stdin (e.g. in a UNIX pipe line) and perform SQL queries?
Rather than SQL queries, you would be using the R language. Unless you use a package like sqldf. stdin can be read just like any other file.
#!/usr/bin/env Rscript
library(sqldf, quietly=TRUE)
statement
then we can call ps -Ao user | Rsql 'select USER, count(*) as nprocesses from a group by USER limit 5'
to get the output USER nprocesses
1 avahi 2
2 colord 1
3 daemon 1
4 marcle 136
5 messagebus 1