2

I have an executable C program (./saucy) that I get from running the makefile of Saucy( source code here)

Running ./saucy graphfile

Gets me as output

(0 2)(3 4)
(0 1)(2 4)

How can I call this from an R script? I'm scratching my head even after reading this post.

andandandand
  • 21,946
  • 60
  • 170
  • 271
  • 1
    If you have an executable that you can call from the command line then perhaps this suffices: https://stackoverflow.com/q/5745886/4996248 – John Coleman Dec 17 '17 at 18:27

1 Answers1

3

I've only got the saucy command line wrapped into an R function of the same name and have only tested it on macOS and Ubuntu but it tracks with your sample output.

By "wrapped" I mean it does not call a binary, it's a C function called from R. It wasn't to difficult to strip away the cmdline cruft. The authors did a pretty decent job.

devtools::install_github("hrbrmstr/saucy")

library(saucy)

First example file:

graph1 <- saucy::saucy(system.file("extdata", "graphfile", package="saucy"))

graph1
## (0 2)(3 4)
## (0 1)(2 4)
## 
##           input_file: graphfile
##             vertices: 5
##                edges: 5
##      group_size_base: 1
##       group_size_exp: 1
##               levels: 3
##                nodes: 7
##           generators: 2
##        total_support: 8
##      average_support: 4
##  nodes_per_generator: 3.5
##            bad_nodes: 0

str(graph1)
## List of 13
##  $ input_file         : chr "/Library/Frameworks/R.framework/Versions/3.4/Resources/library/saucy/extdata/graphfile"
##  $ vertices           : int 5
##  $ edges              : int 5
##  $ group_size_base    : num 1
##  $ group_size_exp     : int 1
##  $ levels             : int 3
##  $ nodes              : int 7
##  $ generators         : int 2
##  $ total_support      : int 8
##  $ average_support    : num 4
##  $ nodes_per_generator: num 3.5
##  $ bad_nodes          : int 0
##  $ printed_output     : chr [1:2] "(0 2)(3 4)" "(0 1)(2 4)"
##  - attr(*, "class")= chr [1:2] "saucy" "list"

Second example file:

graph2 <- saucy::saucy(system.file("extdata", "graphfile2", package="saucy"))

graph2
## (3 5)
## (3 6)(4 5)
## (0 1)
## (0 2)
## 
##           input_file: graphfile2
##             vertices: 7
##                edges: 7
##      group_size_base: 4.8
##       group_size_exp: 1
##               levels: 5
##                nodes: 13
##           generators: 4
##        total_support: 10
##      average_support: 2.5
##  nodes_per_generator: 3.25
##            bad_nodes: 0


str(graph2)
## List of 13
##  $ input_file         : chr "/Library/Frameworks/R.framework/Versions/3.4/Resources/library/saucy/extdata/graphfile2"
##  $ vertices           : int 7
##  $ edges              : int 7
##  $ group_size_base    : num 4.8
##  $ group_size_exp     : int 1
##  $ levels             : int 5
##  $ nodes              : int 13
##  $ generators         : int 4
##  $ total_support      : int 10
##  $ average_support    : num 2.5
##  $ nodes_per_generator: num 3.25
##  $ bad_nodes          : int 0
##  $ printed_output     : chr [1:4] "(3 5)" "(3 6)(4 5)" "(0 1)" "(0 2)"
##  - attr(*, "class")= chr [1:2] "saucy" "list"

shatter is wrapped as well.

I can also make it take real graph structures at some point vs read serialized ones, but I don't know how popular this library/tools is so can't commit to a time-frame.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
  • thanks for the effort, I got the following list of errors when trying to install from devtools, I'm on Ubuntu 14.04 using R 3.3.1 https://gist.github.com/andandandand/8c2f5b8425940555acf0aa639b6073ef – andandandand Dec 18 '17 at 22:32
  • Can you file a github issue with that? – hrbrmstr Dec 18 '17 at 23:53